aboutsummaryrefslogtreecommitdiffstats
path: root/util/dataforms.lua
diff options
context:
space:
mode:
authorFlorian Zeitz <florob@babelmonkeys.de>2011-12-02 19:24:54 +0100
committerFlorian Zeitz <florob@babelmonkeys.de>2011-12-02 19:24:54 +0100
commit6033bbbd91b4c925b78cc05c873c4f249177c555 (patch)
treee6d860261d6736f7de03c523e914a77198a3694c /util/dataforms.lua
parentd531e402d09d48774806fead2b497d34ea8d79c1 (diff)
downloadprosody-6033bbbd91b4c925b78cc05c873c4f249177c555.tar.gz
prosody-6033bbbd91b4c925b78cc05c873c4f249177c555.zip
util.dataforms: Fix form verification
Diffstat (limited to 'util/dataforms.lua')
-rw-r--r--util/dataforms.lua20
1 files changed, 13 insertions, 7 deletions
diff --git a/util/dataforms.lua b/util/dataforms.lua
index e4d24cf6..b69df819 100644
--- a/util/dataforms.lua
+++ b/util/dataforms.lua
@@ -120,12 +120,18 @@ function form_t.data(layout, stanza)
end
end
- local reader = field_readers[field.type];
- local verifier = field.verifier or field_verifiers[field.type];
- if reader then
- data[field.name] = reader(tag);
- if verifier then
- errors[field.name] = verifier(data[field.name], tag, field.required);
+ if not tag then
+ if field.required then
+ errors[field.name] = "Required value missing";
+ end
+ else
+ local reader = field_readers[field.type];
+ local verifier = field.verifier or field_verifiers[field.type];
+ if reader then
+ data[field.name] = reader(tag);
+ if verifier then
+ errors[field.name] = verifier(data[field.name], tag, field.required);
+ end
end
end
end
@@ -161,7 +167,7 @@ field_readers["jid-single"] =
field_verifiers["jid-single"] =
function (data, field_tag, required)
- if #data == 0 and required then
+ if ((not data) or (#data == 0)) and required then
return "Required value missing";
end
if not jid_prep(data) then