Skip to content

Commit

Permalink
* Fix unquoted attribute handling in XML mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Wielemaker committed Oct 28, 2002
1 parent 78108d7 commit 1f77390
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
* FIXED: Properly handle unquoted attributes at the end of an empty element
in XML mode <foo bar=10/>

* FIXED: #CONREF attribute handling in elements with declared content
(CDATA/RCDATA). Richard O'Keefe.

Expand Down
3 changes: 3 additions & 0 deletions Test/att.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0"?>

<foo bar=10/>
2 changes: 2 additions & 0 deletions Test/ok/att.ok
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[element(foo, [bar='10'], [])].
[].
2 changes: 1 addition & 1 deletion Test/test.pl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
dotest(_).

test(File) :-
format('Test ~w ... ', [File]),
format('~NTest ~w ... ', [File]),
flush_output,
load_file(File, Term),
ground(Term), % make sure
Expand Down
15 changes: 6 additions & 9 deletions parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -1048,14 +1048,13 @@ itake_nmtoken_chars(dtd *dtd, const ichar *in, ichar *out, int len)
function accepts anything except > / \0 and blanks.
JW: I decided to accept / as part of an unquoted in SGML-mode if
shorttag is disabled as well as in XML mode if it is not followed
by a >
shorttag is disabled as well as in XML mode if it is not the
end of the begin-element
*/

static ichar const *
itake_unquoted(dtd *dtd, ichar const *in, ichar *out, int len)
{ ichar const end1 = dtd->charfunc->func[CF_STAGC]; /* > */
ichar const end2 = dtd->charfunc->func[CF_ETAGO2]; /* / */
{ ichar const end2 = dtd->charfunc->func[CF_ETAGO2]; /* / */
ichar c;

/* skip leading layout. Do NOT skip comments! --x-- is a value! */
Expand All @@ -1064,10 +1063,9 @@ itake_unquoted(dtd *dtd, ichar const *in, ichar *out, int len)

/* copy the attribute to out[] */
while ( !HasClass(dtd, c, CH_BLANK) &&
c != '\0' &&
c != end1 )
c != '\0' )
{ if ( c == end2 && (dtd->shorttag ||
(in[1] == end1 && dtd->dialect != DL_SGML)) )
(in[1] == '\0' && dtd->dialect != DL_SGML)) )
break;

if ( --len > 0 )
Expand Down Expand Up @@ -3015,8 +3013,7 @@ get_attribute_value(dtd_parser *p, ichar const *decl, sgml_attribute *att)
: HasClass(dtd, c, CH_NAME) ? NAM_LATER : /* oops! */ ANY_OTHER;
}
}
if (dtd->dialect != DL_SGML
|| token == YET_EMPTY || (token & ANY_OTHER) != 0)
if ( token == YET_EMPTY || (token & ANY_OTHER) != 0)
gripe(ERC_SYNTAX_WARNING, "Attribute value requires quotes", buf);

if (!dtd->case_sensitive && att->definition->type != AT_CDATA)
Expand Down

0 comments on commit 1f77390

Please sign in to comment.