Fix bug with entity containing ] or ]]

This commit is contained in:
James Clark 1998-05-02 03:14:22 +00:00
parent a9a9179d63
commit 7e71c8f5d5
3 changed files with 24 additions and 2 deletions

View file

@ -755,6 +755,25 @@ doContent(XML_Parser parser,
} while (s != lim);
}
break;
case XML_TOK_TRAILING_RSQB:
if (nextPtr) {
*nextPtr = s;
return XML_ERROR_NONE;
}
if (characterDataHandler) {
char *dataPtr = dataBuf;
XmlConvert(enc, XML_UTF8_ENCODING, &s, end, &dataPtr, dataBufEnd);
characterDataHandler(userData, dataBuf, dataPtr - dataBuf);
}
if (startTagLevel == 0) {
errorPtr = end;
return XML_ERROR_NO_ELEMENTS;
}
if (tagLevel != startTagLevel) {
errorPtr = end;
return XML_ERROR_ASYNC_ENTITY;
}
return XML_ERROR_NONE;
case XML_TOK_DATA_CHARS:
if (characterDataHandler) {
do {

View file

@ -29,6 +29,9 @@ extern "C" {
#define XMLTOKAPI /* as nothing */
#endif
/* The following token may be returned by XmlContentTok */
#define XML_TOK_TRAILING_RSQB -5 /* ] or ]] at the end of the scan; might be start of
illegal ]]> sequence */
/* The following tokens may be returned by both XmlPrologTok and XmlContentTok */
#define XML_TOK_NONE -4 /* The string to be scanned is empty */
#define XML_TOK_TRAILING_CR -3 /* A CR at the end of the scan;

View file

@ -694,12 +694,12 @@ int PREFIX(contentTok)(const ENCODING *enc, const char *ptr, const char *end,
case BT_RSQB:
ptr += MINBPC;
if (ptr == end)
return XML_TOK_PARTIAL;
return XML_TOK_TRAILING_RSQB;
if (!CHAR_MATCHES(enc, ptr, ']'))
break;
ptr += MINBPC;
if (ptr == end)
return XML_TOK_PARTIAL;
return XML_TOK_TRAILING_RSQB;
if (!CHAR_MATCHES(enc, ptr, '>')) {
ptr -= MINBPC;
break;