equal
deleted
inserted
replaced
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)); |