XML parser incorrectly accepts document without top-level element
Imported from http://bugzilla.roxen.com/bugzilla/show_bug.cgi?id=3932
Reported by Jonas Wallden jonasw@roxen.com
Both of these examples should signal parse errors:
ceylon:server $ ~/pike/7.4/bin/pike
Pike v7.4 release 301 running Hilfe v3.5 (Incremental Pike Frontend)
> function cb = lambda(mixed ...foo) { werror("%O\n", foo); };
> Parser.XML.Simple()->parse("", cb);
(1) Result: ({ })
> Parser.XML.Simple()->parse("<?xml version='1.0'?>", cb);
({ /* 5 elements */
"<?xml",
0,
([ /* 1 element */
"version":"1.0"
]),
0,
([ /* 1 element */
"location":21
])
})
(2) Result: ({ })
Relevant productions from the XML specification:
[1] document ::= prolog element Misc* [39] element ::= EmptyElemTag | STag content ETag [40] STag ::= '<' Name (S Attribute)* S? '>' [44] EmptyElemTag ::= '<' Name (S Attribute)* S? '/>'