Software /
code /
prosody
Comparison
util/stanza.lua @ 12799:3784a8ce0596 0.12 0.12.2
Merge 0.11->0.12
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 12 Dec 2022 07:07:13 +0100 |
parent | 12724:5b5b428d67e2 |
parent | 12797:be09ac8300a7 |
comparison
equal
deleted
inserted
replaced
12796:d7853bbc88ea | 12799:3784a8ce0596 |
---|---|
32 -- luacheck: std none | 32 -- luacheck: std none |
33 | 33 |
34 local stanza_mt = { __name = "stanza" }; | 34 local stanza_mt = { __name = "stanza" }; |
35 stanza_mt.__index = stanza_mt; | 35 stanza_mt.__index = stanza_mt; |
36 | 36 |
37 -- Basic check for valid XML character data. | |
38 -- Disallow control characters. | |
39 -- Tab U+09 and newline U+0A are allowed. | |
40 -- For attributes, allow the \1 separator between namespace and name. | |
37 local function valid_xml_cdata(str, attr) | 41 local function valid_xml_cdata(str, attr) |
38 return not s_find(str, attr and "[^\1\9\10\13\20-~\128-\247]" or "[^\9\10\13\20-~\128-\247]"); | 42 return not s_find(str, attr and "[^\1\9\10\13\20-\255]" or "[^\9\10\13\20-\255]"); |
39 end | 43 end |
40 | 44 |
41 local function check_name(name, name_type) | 45 local function check_name(name, name_type) |
42 if type(name) ~= "string" then | 46 if type(name) ~= "string" then |
43 error("invalid "..name_type.." name: expected string, got "..type(name)); | 47 error("invalid "..name_type.." name: expected string, got "..type(name)); |