diff --git a/ChangeLog b/ChangeLog index efb772d..c7ffe33 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Jun 6, 2007 + + * FIXED: give error on bad entities in XML mode. + Feb 6, 2007 * MODIFIED: xml_quote_attribute no longer maps ' to ' See note in diff --git a/Test/badxmlent.xml b/Test/badxmlent.xml new file mode 100644 index 0000000..c25d3fc --- /dev/null +++ b/Test/badxmlent.xml @@ -0,0 +1,5 @@ + + + + John & Mary + diff --git a/Test/ok/badxmlent.ok b/Test/ok/badxmlent.ok new file mode 100644 index 0000000..66de8fb --- /dev/null +++ b/Test/ok/badxmlent.ok @@ -0,0 +1,2 @@ +[element(test, [a='John & Mary'], ['\n John & Mary\n'])]. +[sgml(sgml_parser(1949540), 'badxmlent.xml', 3, 'Syntax error: Illegal entity, found "& Mary""'), sgml(sgml_parser(1949540), 'badxmlent.xml', 4, 'Syntax error: Illegal entity, found "& "')]. diff --git a/parser.c b/parser.c index d5c4840..71d16a6 100644 --- a/parser.c +++ b/parser.c @@ -596,6 +596,9 @@ expand_entities(dtd_parser *p, const ichar *in, int len, ocharbuf *out) continue; } + + if ( dtd->dialect != DL_SGML ) + gripe(ERC_SYNTAX_ERROR, L"Illegal entity", in); } recover: @@ -4867,7 +4870,15 @@ putchar_dtd_parser(dtd_parser *p, int chr) add_icharbuf(p->buffer, chr); p->state = S_ENT; } else - { add_cdata(p, f[CF_ERO]); + { if ( dtd->dialect != DL_SGML ) + { wchar_t buf[3]; + buf[0] = '&'; + buf[1] = chr; + buf[2] = '\0'; + gripe(ERC_SYNTAX_ERROR, L"Illegal entity", buf); + } + + add_cdata(p, f[CF_ERO]); p->state = p->cdata_state; goto reprocess; }