summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Sluift/ElementConvertors/FormConvertor.cpp4
-rw-r--r--Sluift/Tests/FormTest.lua14
2 files changed, 14 insertions, 4 deletions
diff --git a/Sluift/ElementConvertors/FormConvertor.cpp b/Sluift/ElementConvertors/FormConvertor.cpp
index a0e3dfe..85f40a1 100644
--- a/Sluift/ElementConvertors/FormConvertor.cpp
+++ b/Sluift/ElementConvertors/FormConvertor.cpp
@@ -287,9 +287,7 @@ namespace {
if (!payload->getInstructions().empty()) {
result["instructions"] = Lua::valueRef(payload->getInstructions());
}
- if (!payload->getFields().empty()) {
- result["fields"] = valueRef(convertFieldListToLua(payload->getFields()));
- }
+ result["fields"] = valueRef(convertFieldListToLua(payload->getFields()));
if (!payload->getReportedFields().empty()) {
result["reported_fields"] = valueRef(convertFieldListToLua(payload->getReportedFields()));
}
diff --git a/Sluift/Tests/FormTest.lua b/Sluift/Tests/FormTest.lua
index 8065360..d584646 100644
--- a/Sluift/Tests/FormTest.lua
+++ b/Sluift/Tests/FormTest.lua
@@ -1,5 +1,5 @@
--[[
- Copyright (c) 2013 Isode Limited.
+ Copyright (c) 2013-2016 Isode Limited.
All rights reserved.
See the COPYING file for more information.
--]]
@@ -90,3 +90,15 @@ assert(type(text_multi_field['value']) == 'table')
--print(sluift.to_xml({type = 'form', data = form}))
+
+-- test parsing an empty form -- this had issues as reported in SWIFT-174
+empty_form = [[<x xmlns='jabber:x:data' type='form'/>]]
+form = sluift.from_xml(empty_form)
+-- and check if we can access all fields without problems
+assert(type(form._type))
+assert(type(form.title))
+assert(type(form.instructions))
+assert(type(form.type))
+assert(type(form.fields))
+assert(type(form.items))
+assert(type(form.reported_items))