XML missing encoding error
parent
2aa7df0e55
commit
a282789910
|
@ -3,7 +3,7 @@
|
||||||
USING: kernel namespaces xml.name io.encodings.utf8 xml.elements
|
USING: kernel namespaces xml.name io.encodings.utf8 xml.elements
|
||||||
io.encodings.utf16 xml.tokenize xml.state math ascii sequences
|
io.encodings.utf16 xml.tokenize xml.state math ascii sequences
|
||||||
io.encodings.string io.encodings combinators accessors
|
io.encodings.string io.encodings combinators accessors
|
||||||
xml.data io.encodings.iana ;
|
xml.data io.encodings.iana xml.errors ;
|
||||||
IN: xml.autoencoding
|
IN: xml.autoencoding
|
||||||
|
|
||||||
: decode-stream ( encoding -- )
|
: decode-stream ( encoding -- )
|
||||||
|
@ -35,7 +35,10 @@ IN: xml.autoencoding
|
||||||
|
|
||||||
: prolog-encoding ( prolog -- )
|
: prolog-encoding ( prolog -- )
|
||||||
encoding>> dup "UTF-16" =
|
encoding>> dup "UTF-16" =
|
||||||
[ drop ] [ name>encoding [ decode-stream ] when* ] if ;
|
[ drop ] [
|
||||||
|
dup name>encoding
|
||||||
|
[ decode-stream ] [ bad-encoding ] ?if
|
||||||
|
] if ;
|
||||||
|
|
||||||
: instruct-encoding ( instruct/prolog -- )
|
: instruct-encoding ( instruct/prolog -- )
|
||||||
dup prolog?
|
dup prolog?
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
USING: continuations xml xml.errors tools.test kernel arrays
|
USING: continuations xml xml.errors tools.test kernel arrays
|
||||||
xml.data quotations fry ;
|
xml.data quotations fry byte-arrays ;
|
||||||
IN: xml.errors.tests
|
IN: xml.errors.tests
|
||||||
|
|
||||||
: xml-error-test ( expected-error xml-string -- )
|
: xml-error-test ( expected-error xml-string -- )
|
||||||
|
@ -40,3 +40,4 @@ T{ bad-doctype f 1 22 T{ opener { name T{ name f "" "foo" "" } } { attrs T{ attr
|
||||||
T{ disallowed-char f 1 4 1 } "<x>\u000001</x>" xml-error-test
|
T{ disallowed-char f 1 4 1 } "<x>\u000001</x>" xml-error-test
|
||||||
T{ missing-close f 1 8 } "<!-- foo" xml-error-test
|
T{ missing-close f 1 8 } "<!-- foo" xml-error-test
|
||||||
T{ misplaced-directive f 1 9 "ENTITY" } "<!ENTITY foo 'bar'><x/>" xml-error-test
|
T{ misplaced-directive f 1 9 "ENTITY" } "<!ENTITY foo 'bar'><x/>" xml-error-test
|
||||||
|
[ "<?xml version='1.0' encoding='foobar'?>" >byte-array bytes>xml ] [ T{ bad-encoding f 1 39 "foobar" } = ] must-fail-with
|
||||||
|
|
|
@ -338,5 +338,14 @@ TUPLE: bad-doctype < xml-error-at contents ;
|
||||||
M: bad-doctype summary
|
M: bad-doctype summary
|
||||||
call-next-method "\nDTD contains invalid object" append ;
|
call-next-method "\nDTD contains invalid object" append ;
|
||||||
|
|
||||||
|
TUPLE: bad-encoding < xml-error-at encoding ;
|
||||||
|
: bad-encoding ( encoding -- * )
|
||||||
|
\ bad-encoding xml-error-at
|
||||||
|
swap >>encoding
|
||||||
|
throw ;
|
||||||
|
M: bad-encoding summary
|
||||||
|
call-next-method
|
||||||
|
"\nEncoding in XML document does not exist" append ;
|
||||||
|
|
||||||
UNION: xml-error
|
UNION: xml-error
|
||||||
multitags notags pre/post-content xml-error-at ;
|
multitags notags pre/post-content xml-error-at ;
|
||||||
|
|
Loading…
Reference in New Issue