aboutsummaryrefslogtreecommitdiffstats
path: root/util/stanza.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2022-11-22 23:56:01 +0100
committerKim Alvefur <zash@zash.se>2022-11-22 23:56:01 +0100
commit4fa3808e8dfccb12c11ad2b22130765307750851 (patch)
tree96fbe6dec28cf867a32c04436cef805c9befefcf /util/stanza.lua
parent6bd9bed561efc2729b346dda6c07817e3ae26b18 (diff)
downloadprosody-4fa3808e8dfccb12c11ad2b22130765307750851.tar.gz
prosody-4fa3808e8dfccb12c11ad2b22130765307750851.zip
util.stanza: Allow U+7F0.11.14
Allowed by XML despite arguably being a control character. Drops the part of the range meant to rule out octets invalid in UTF-8 (\247 starts a 4-byte sequence), since UTF-8 correctness is validated by util.encodings.utf8.valid().
Diffstat (limited to 'util/stanza.lua')
-rw-r--r--util/stanza.lua6
1 files changed, 5 insertions, 1 deletions
diff --git a/util/stanza.lua b/util/stanza.lua
index a8c619d0..3cd56c5f 100644
--- a/util/stanza.lua
+++ b/util/stanza.lua
@@ -45,8 +45,12 @@ local _ENV = nil;
local stanza_mt = { __name = "stanza" };
stanza_mt.__index = stanza_mt;
+-- Basic check for valid XML character data.
+-- Disallow control characters.
+-- Tab U+09 and newline U+0A are allowed.
+-- For attributes, allow the \1 separator between namespace and name.
local function valid_xml_cdata(str, attr)
- return not s_find(str, attr and "[^\1\9\10\13\20-~\128-\247]" or "[^\9\10\13\20-~\128-\247]");
+ return not s_find(str, attr and "[^\1\9\10\13\20-\255]" or "[^\9\10\13\20-\255]");
end
local function check_name(name, name_type)