diff options
author | kwaclaw <kwaclaw> | 2006-07-10 18:59:52 +0000 |
---|---|---|
committer | kwaclaw <kwaclaw> | 2006-07-10 18:59:52 +0000 |
commit | d4cd186487b0c4b66a6d4ecbc19824ce9f906035 (patch) | |
tree | 4a98ef1bad6f24be1ade91b2613685ba1d365d20 | |
parent | 4bf8fe13332ad960ab1dc7efb5ee84d121f82a7a (diff) | |
download | libexpat-d4cd186487b0c4b66a6d4ecbc19824ce9f906035.tar.gz |
Improved fix for issues # 1515266 and # 1515600. Will now preserve the
"failover to default handler" logic. Note: clearing the character data handler
does not take effect immediately anymore.
-rw-r--r-- | doc/reference.html | 5 | ||||
-rw-r--r-- | lib/xmlparse.c | 76 |
2 files changed, 43 insertions, 38 deletions
diff --git a/doc/reference.html b/doc/reference.html index e2ced9a..d3eff83 100644 --- a/doc/reference.html +++ b/doc/reference.html @@ -1290,7 +1290,10 @@ is <em>NOT nul-terminated</em>. You have to use the length argument to deal with the end of the string. A single block of contiguous text free of markup may still result in a sequence of calls to this handler. In other words, if you're searching for a pattern in the text, it may -be split across calls to this handler.</p> +be split across calls to this handler. Note: Setting this handler to NULL +may <em>NOT immediately</em> terminate call-backs if the parser is currently +processing such a single block of contiguous markup-free text, as the parser +will continue calling back until the end of the block is reached.</p> </div> <div class="handler"> diff --git a/lib/xmlparse.c b/lib/xmlparse.c index faa841f..db9c174 100644 --- a/lib/xmlparse.c +++ b/lib/xmlparse.c @@ -2544,29 +2544,30 @@ doContent(XML_Parser parser, } *nextPtr = end; return XML_ERROR_NONE; - case XML_TOK_DATA_CHARS: - if (MUST_CONVERT(enc, s)) { - for (;;) { - if (characterDataHandler) { - ICHAR *dataPtr = (ICHAR *)dataBuf; - XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd); - *eventEndPP = s; - characterDataHandler(handlerArg, dataBuf, - (int)(dataPtr - (ICHAR *)dataBuf)); - if (s == next) - break; - *eventPP = s; + case XML_TOK_DATA_CHARS: + { + XML_CharacterDataHandler charDataHandler = characterDataHandler; + if (charDataHandler) { + if (MUST_CONVERT(enc, s)) { + for (;;) { + ICHAR *dataPtr = (ICHAR *)dataBuf; + XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd); + *eventEndPP = s; + charDataHandler(handlerArg, dataBuf, + (int)(dataPtr - (ICHAR *)dataBuf)); + if (s == next) + break; + *eventPP = s; + } } else - break; + charDataHandler(handlerArg, + (XML_Char *)s, + (int)((XML_Char *)next - (XML_Char *)s)); } + else if (defaultHandler) + reportDefault(parser, enc, s, next); } - else if (characterDataHandler) - characterDataHandler(handlerArg, - (XML_Char *)s, - (int)((XML_Char *)next - (XML_Char *)s)); - else if (defaultHandler) - reportDefault(parser, enc, s, next); break; case XML_TOK_PI: if (!reportProcessingInstruction(parser, enc, s, next)) @@ -3127,28 +3128,29 @@ doCdataSection(XML_Parser parser, reportDefault(parser, enc, s, next); break; case XML_TOK_DATA_CHARS: - if (MUST_CONVERT(enc, s)) { - for (;;) { - if (characterDataHandler) { - ICHAR *dataPtr = (ICHAR *)dataBuf; - XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd); - *eventEndPP = next; - characterDataHandler(handlerArg, dataBuf, - (int)(dataPtr - (ICHAR *)dataBuf)); - if (s == next) - break; - *eventPP = s; + { + XML_CharacterDataHandler charDataHandler = characterDataHandler; + if (charDataHandler) { + if (MUST_CONVERT(enc, s)) { + for (;;) { + ICHAR *dataPtr = (ICHAR *)dataBuf; + XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd); + *eventEndPP = next; + charDataHandler(handlerArg, dataBuf, + (int)(dataPtr - (ICHAR *)dataBuf)); + if (s == next) + break; + *eventPP = s; + } } else - break; + charDataHandler(handlerArg, + (XML_Char *)s, + (int)((XML_Char *)next - (XML_Char *)s)); } + else if (defaultHandler) + reportDefault(parser, enc, s, next); } - else if (characterDataHandler) - characterDataHandler(handlerArg, - (XML_Char *)s, - (int)((XML_Char *)next - (XML_Char *)s)); - else if (defaultHandler) - reportDefault(parser, enc, s, next); break; case XML_TOK_INVALID: *eventPP = next; |