diff options
author | Matthew Wild <mwild1@gmail.com> | 2018-03-16 14:51:24 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2018-03-16 14:51:24 +0000 |
commit | d0a4392817106074a0470a6039f024baa593c748 (patch) | |
tree | 9f92c5b23cf04c6b18282fd4ff47cb52e4fc9391 /spec/util_stanza_spec.lua | |
parent | 6d97f869e8dc7c148b5cc196f3e83ebc9bf72ca0 (diff) | |
download | prosody-d0a4392817106074a0470a6039f024baa593c748.tar.gz prosody-d0a4392817106074a0470a6039f024baa593c748.zip |
util.stanza: Add stricter validation for data passed to stanza builder API
Diffstat (limited to 'spec/util_stanza_spec.lua')
-rw-r--r-- | spec/util_stanza_spec.lua | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/util_stanza_spec.lua b/spec/util_stanza_spec.lua index 7543ffe7..ea3ef4c9 100644 --- a/spec/util_stanza_spec.lua +++ b/spec/util_stanza_spec.lua @@ -164,4 +164,38 @@ describe("util.stanza", function() assert.are.equal(r.tags[1].tags[1].name, "service-unavailable"); end); end); + + describe("#invalid", function () + it("name should be rejected", function () + assert.has_error(function () + st.stanza(1234); + end); + assert.has_error(function () + st.stanza({}); + end); + assert.has_error(function () + st.stanza(); + end); + assert.has_error(function () + st.stanza(""); + end); + assert.has_error(function () + st.stanza(string.char(0xC0)); + end); + assert.has_error(function () + st.stanza(string.char(0xF4, 0x90, 0x80, 0x80)); + end); + assert.has_error(function () + st.stanza("<>"); + end); + assert.has_error(function () + st.stanza("&"); + end); + end); + it("UTF-8 should be rejected", function () + assert.has_error(function () + st.stanza("tag"):text("hello "..string.char(0xF4, 0x90, 0x80, 0x80).." world"); + end); + end); + end); end); |