10 <a:z/> |
10 <a:z/> |
11 </y> |
11 </y> |
12 <a:z/> <!-- prefix 'a' is nil here, but should be 'b' --> |
12 <a:z/> <!-- prefix 'a' is nil here, but should be 'b' --> |
13 </x> |
13 </x> |
14 ]] |
14 ]] |
15 local stanza = xml.parse(x); |
15 local stanza = xml.parse(x, {allow_comments = true}); |
16 assert.are.equal(stanza.tags[2].attr.xmlns, "b"); |
16 assert.are.equal(stanza.tags[2].attr.xmlns, "b"); |
17 assert.are.equal(stanza.tags[2].namespaces["a"], "b"); |
17 assert.are.equal(stanza.tags[2].namespaces["a"], "b"); |
18 end); |
18 end); |
|
19 |
|
20 it("should reject doctypes", function() |
|
21 local x = "<!DOCTYPE foo []><foo/>"; |
|
22 local ok = xml.parse(x); |
|
23 assert.falsy(ok); |
|
24 end); |
|
25 |
|
26 it("should reject comments by default", function() |
|
27 local x = "<foo><!-- foo --></foo>"; |
|
28 local ok = xml.parse(x); |
|
29 assert.falsy(ok); |
|
30 end); |
|
31 |
|
32 it("should allow comments if asked nicely", function() |
|
33 local x = "<foo><!-- foo --></foo>"; |
|
34 local stanza = xml.parse(x, {allow_comments = true}); |
|
35 assert.are.equal(stanza.name, "foo"); |
|
36 assert.are.equal(#stanza, 0); |
|
37 end); |
|
38 |
|
39 it("should reject processing instructions", function() |
|
40 local x = "<foo><?php die(); ?></foo>"; |
|
41 local ok = xml.parse(x); |
|
42 assert.falsy(ok); |
|
43 end); |
|
44 |
|
45 it("should allow an xml declaration", function() |
|
46 local x = "<?xml version='1.0'?><foo/>"; |
|
47 local stanza = xml.parse(x); |
|
48 assert.truthy(stanza); |
|
49 assert.are.equal(stanza.name, "foo"); |
|
50 end); |
19 end); |
51 end); |
20 end); |
52 end); |