aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2015-09-12 17:49:47 +0200
committerKim Alvefur <zash@zash.se>2015-09-12 17:49:47 +0200
commite91df7d788d51243d6a560aab0ac36ac3e948c7e (patch)
treebea3749980c8426c9528f77676e0b20ab3f7da1a /util
parent5739f89a5d6d64d50a01874c03169a23ac1a1e98 (diff)
downloadprosody-e91df7d788d51243d6a560aab0ac36ac3e948c7e.tar.gz
prosody-e91df7d788d51243d6a560aab0ac36ac3e948c7e.zip
util.dataforms: Fix interaction of required fields and empty string values (fixes #521)
Diffstat (limited to 'util')
-rw-r--r--util/dataforms.lua7
1 files changed, 4 insertions, 3 deletions
diff --git a/util/dataforms.lua b/util/dataforms.lua
index 30b5344a..05846ab3 100644
--- a/util/dataforms.lua
+++ b/util/dataforms.lua
@@ -147,11 +147,12 @@ end
local function simple_text(field_tag, required)
local data = field_tag:get_child_text("value");
- if data and #data > 0 then
- return data
- elseif required then
+ -- XEP-0004 does not say if an empty string is acceptable for a required value
+ -- so we will follow HTML5 which says that empty string means missing
+ if required and (data == nil or data == "") then
return nil, "Required value missing";
end
+ return data; -- Return whatever get_child_text returned, even if empty string
end
field_readers["text-single"] = simple_text;