xml: Word names like foo]] are not allowed.

Names like foo]] are alternative syntax for closing foo[ ] forms, e.g. foo[ foo].

foo]] parses as a foo] closer and then another ]
modern-harvey2
Doug Coleman 2017-09-24 13:15:10 -05:00
parent c3e137c08a
commit 341f2c3307
3 changed files with 6 additions and 5 deletions

View File

@ -30,7 +30,7 @@ T{ bad-name f 1 3 "-" } "<-/>" xml-error-test
T{ quoteless-attr f 1 12 } "<x value=<->/>" xml-error-test T{ quoteless-attr f 1 12 } "<x value=<->/>" xml-error-test
T{ quoteless-attr f 1 10 } "<x value=3/>" xml-error-test T{ quoteless-attr f 1 10 } "<x value=3/>" xml-error-test
T{ attr-w/< f 1 11 } "<x value='<'/>" xml-error-test T{ attr-w/< f 1 11 } "<x value='<'/>" xml-error-test
T{ text-w/]]> f 1 6 } "<x>]]></x>" xml-error-test T{ text-with-double-close-bracket f 1 6 } "<x>]]></x>" xml-error-test
T{ duplicate-attr f 1 21 T{ name { space "" } { main "this" } } V{ "a" "b" } } "<x this='a' this='b'/>" xml-error-test T{ duplicate-attr f 1 21 T{ name { space "" } { main "this" } } V{ "a" "b" } } "<x this='a' this='b'/>" xml-error-test
T{ bad-cdata f 1 3 } "<![CDATA[]]><x/>" xml-error-test T{ bad-cdata f 1 3 } "<![CDATA[]]><x/>" xml-error-test
T{ bad-cdata f 1 7 } "<x/><![CDATA[]]>" xml-error-test T{ bad-cdata f 1 7 } "<x/><![CDATA[]]>" xml-error-test

View File

@ -92,7 +92,7 @@ XML-ERROR: quoteless-attr ;
XML-ERROR: attr-w/< ; XML-ERROR: attr-w/< ;
XML-ERROR: text-w/]]> ; XML-ERROR: text-with-double-close-bracket ;
XML-ERROR: duplicate-attr key values ; XML-ERROR: duplicate-attr key values ;

View File

@ -152,14 +152,15 @@ HINTS: next* { spot } ;
: parse-char ( quot: ( ch -- ? ) -- seq ) : parse-char ( quot: ( ch -- ? ) -- seq )
512 <sbuf> [ spot get (parse-char) ] keep "" like ; inline 512 <sbuf> [ spot get (parse-char) ] keep "" like ; inline
: assure-no-]]> ( pos char -- pos' ) : assure-no-double-bracket ( pos char -- pos' )
"]]>" next-matching dup 2 > [ text-w/]]> ] when ; inline "]]>" next-matching
dup 2 > [ text-with-double-close-bracket ] when ; inline
:: parse-text ( -- string ) :: parse-text ( -- string )
depth get zero? :> no-text depth get zero? :> no-text
0 :> pos! 0 :> pos!
|[ char | |[ char |
pos char assure-no-]]> pos! pos char assure-no-double-bracket pos!
no-text [ no-text [
char blank? char char: < eq? or [ char blank? char char: < eq? or [
char 1string t pre/post-content char 1string t pre/post-content