Skip to content

Commit

Permalink
* Fixed Bug#212: � is an error
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Wielemaker committed Dec 15, 2004
1 parent cf77813 commit 78e0882
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Dec 15, 2004

* FIXED: Bug#212: Disallow � character entities.

Nov 25, 2004

* FIXED: utf-8 tests, avoid conflict with UTF-8 support in Prolog
Expand Down
1 change: 1 addition & 0 deletions Test/cent-nul.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<test>This content holds a &#0; byte that should be skipped</test>
2 changes: 2 additions & 0 deletions Test/ok/cent-nul.ok
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[element(test, [], ['This content holds a byte that should be skipped'])].
[sgml(sgml_parser(482992), 'cent-nul.xml', 1, 'Syntax error: Bad character entity, found "#0"')].
23 changes: 17 additions & 6 deletions parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,13 @@ expand_pentities(dtd_parser *p, const ichar *in, ichar *out, int len)

if ( (s=isee_character_entity(dtd, in, &chr)) &&
representable_char(p, chr) )
{ *out++ = chr;
in = s;
continue;
{ if ( chr == 0 )
{ gripe(ERC_SYNTAX_ERROR, "Illegal character entity", in);
} else
{ *out++ = chr;
in = s;
continue;
}
}
}

Expand Down Expand Up @@ -520,7 +524,11 @@ expand_entities(dtd_parser *p, const ichar *in, ochar *out, int len)

if ( (s=isee_character_entity(dtd, in, &chr)) )
{ if ( chr <= 0 || chr >= OUTPUT_CHARSET_SIZE )
gripe(ERC_REPRESENTATION, "character");
{ if ( chr == 0 )
gripe(ERC_SYNTAX_ERROR, "Illegal character entity", in);
else
gripe(ERC_REPRESENTATION, "character");
}
if ( --len <= 0 )
return gripe(ERC_REPRESENTATION, "CDATA string too long");
*out++ = chr;
Expand Down Expand Up @@ -4133,7 +4141,7 @@ process_entity(dtd_parser *p, const ichar *name)
{ if ( name[0] == '#' ) /* #charcode: character entity */
{ int v = char_entity_value(name);

if ( v < 0 )
if ( v <= 0 )
return gripe(ERC_SYNTAX_ERROR, "Bad character entity", name);

if ( v >= OUTPUT_CHARSET_SIZE )
Expand Down Expand Up @@ -4177,7 +4185,10 @@ process_entity(dtd_parser *p, const ichar *name)
{ case EC_SGML:
case EC_CDATA:
if ( (s=isee_character_entity(dtd, text, &chr)) && *s == '\0' )
{ if ( p->blank_cdata == TRUE && !HasClass(dtd, chr, CH_BLANK) )
{ if ( chr == 0 )
return gripe(ERC_SYNTAX_ERROR, "Illegal character entity", text);

if ( p->blank_cdata == TRUE && !HasClass(dtd, chr, CH_BLANK) )
{ p->cdata_must_be_empty = !open_element(p, CDATA_ELEMENT, FALSE);
p->blank_cdata = FALSE;
}
Expand Down

0 comments on commit 78e0882

Please sign in to comment.