From 1f773904f0341961c7b389e7c67678576a4adcb8 Mon Sep 17 00:00:00 2001 From: Jan Wielemaker Date: Mon, 28 Oct 2002 08:55:53 +0000 Subject: [PATCH] * Fix unquoted attribute handling in XML mode --- ChangeLog | 3 +++ Test/att.xml | 3 +++ Test/ok/att.ok | 2 ++ Test/test.pl | 2 +- parser.c | 15 ++++++--------- 5 files changed, 15 insertions(+), 10 deletions(-) create mode 100644 Test/att.xml create mode 100644 Test/ok/att.ok diff --git a/ChangeLog b/ChangeLog index 1cc41e5..66b3cf3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +* FIXED: Properly handle unquoted attributes at the end of an empty element + in XML mode + * FIXED: #CONREF attribute handling in elements with declared content (CDATA/RCDATA). Richard O'Keefe. diff --git a/Test/att.xml b/Test/att.xml new file mode 100644 index 0000000..740795c --- /dev/null +++ b/Test/att.xml @@ -0,0 +1,3 @@ + + + diff --git a/Test/ok/att.ok b/Test/ok/att.ok new file mode 100644 index 0000000..181b871 --- /dev/null +++ b/Test/ok/att.ok @@ -0,0 +1,2 @@ +[element(foo, [bar='10'], [])]. +[]. diff --git a/Test/test.pl b/Test/test.pl index 8d5418f..2c86ed6 100644 --- a/Test/test.pl +++ b/Test/test.pl @@ -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 diff --git a/parser.c b/parser.c index 68664be..daaa721 100644 --- a/parser.c +++ b/parser.c @@ -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! */ @@ -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 ) @@ -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)