Software /
code /
prosody
Changeset
6830:e08f5d081a6c
util.dataforms: Fix interaction of required fields and empty string values (fixes #521)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 12 Sep 2015 17:49:47 +0200 |
parents | 6829:22522443982f |
children | 6831:428b8da1cfce |
files | util/dataforms.lua |
diffstat | 1 files changed, 4 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/util/dataforms.lua Sat Sep 12 17:40:14 2015 +0200 +++ b/util/dataforms.lua Sat Sep 12 17:49:47 2015 +0200 @@ -147,11 +147,12 @@ 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;