Skip to content

Commit

Permalink
* Give error on bad XML entity
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Wielemaker committed Jun 6, 2007
1 parent bb8e14a commit 1a7a2b6
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 5 additions & 0 deletions Test/badxmlent.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0">

<test a="John & Mary">
John & Mary
</test>
2 changes: 2 additions & 0 deletions Test/ok/badxmlent.ok
Original file line number Diff line number Diff line change
@@ -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 "& "')].
13 changes: 12 additions & 1 deletion parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 1a7a2b6

Please sign in to comment.