Mercurial > prosody-hg
comparison spec/util_xml_spec.lua @ 12270:c78639ee6ccb
util.xml: Add an option to allow <?processing instructions?>
These should generally be safe to just ignore, which should be the
default behavior of Expat and LuaExpat
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Fri, 04 Feb 2022 20:47:39 +0100 |
| parents | 53e0ae770917 |
| children |
comparison
equal
deleted
inserted
replaced
| 12269:a19d435dee90 | 12270:c78639ee6ccb |
|---|---|
| 40 local x = "<foo><?php die(); ?></foo>"; | 40 local x = "<foo><?php die(); ?></foo>"; |
| 41 local ok = xml.parse(x); | 41 local ok = xml.parse(x); |
| 42 assert.falsy(ok); | 42 assert.falsy(ok); |
| 43 end); | 43 end); |
| 44 | 44 |
| 45 it("should allow processing instructions if asked nicely", function() | |
| 46 local x = "<?xml-stylesheet href='make-fancy.xsl'?><foo/>"; | |
| 47 local stanza = xml.parse(x, {allow_processing_instructions = true}); | |
| 48 assert.truthy(stanza); | |
| 49 assert.are.equal(stanza.name, "foo"); | |
| 50 end); | |
| 51 | |
| 45 it("should allow an xml declaration", function() | 52 it("should allow an xml declaration", function() |
| 46 local x = "<?xml version='1.0'?><foo/>"; | 53 local x = "<?xml version='1.0'?><foo/>"; |
| 47 local stanza = xml.parse(x); | 54 local stanza = xml.parse(x); |
| 48 assert.truthy(stanza); | 55 assert.truthy(stanza); |
| 49 assert.are.equal(stanza.name, "foo"); | 56 assert.are.equal(stanza.name, "foo"); |
