summaryrefslogtreecommitdiff
path: root/xml.c
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2019-06-11 20:57:16 +0200
committerHiltjo Posthuma <hiltjo@codemadness.org>2019-06-11 20:57:16 +0200
commite1fdd1e49326041e7cbd68876879e51b2a79e973 (patch)
tree8ffed2421a9e7a79e31c0114bf528bfa23ea2be2 /xml.c
parentc020d456846f33ec834ddf9a1656368e502cd67f (diff)
xml: improve cdata and comment callback logic
it used to call both handlers twice at the end for "-->" (comment) or "]]>" (CDATA) with the data "" and length 0. Now it is only called when non-empty. The start and end handlers can still be used.
Diffstat (limited to 'xml.c')
-rw-r--r--xml.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/xml.c b/xml.c
index 0e6f5d8..d6e63b0 100644
--- a/xml.c
+++ b/xml.c
@@ -126,7 +126,7 @@ xml_parsecomment(XMLParser *x)
x->xmlcommentstart(x);
while ((c = GETNEXT()) != EOF) {
if (c == '-' || c == '>') {
- if (x->xmlcomment) {
+ if (x->xmlcomment && datalen) {
x->data[datalen] = '\0';
x->xmlcomment(x, x->data, datalen);
datalen = 0;
@@ -175,7 +175,7 @@ xml_parsecdata(XMLParser *x)
x->xmlcdatastart(x);
while ((c = GETNEXT()) != EOF) {
if (c == ']' || c == '>') {
- if (x->xmlcdata) {
+ if (x->xmlcdata && datalen) {
x->data[datalen] = '\0';
x->xmlcdata(x, x->data, datalen);
datalen = 0;