summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStefan Radomski <github@mintwerk.de>2017-04-26 19:35:29 (GMT)
committerStefan Radomski <github@mintwerk.de>2017-04-26 19:35:29 (GMT)
commit2b9e5d72a31c5060a443a0535d2d139326c51f04 (patch)
treedf7ad0c94f43b5872991f8e223a6b7c9da2f75cd /src
parent3a7350b931705b2ab3aa6f1516512e37038e9899 (diff)
downloaduscxml-2b9e5d72a31c5060a443a0535d2d139326c51f04.zip
uscxml-2b9e5d72a31c5060a443a0535d2d139326c51f04.tar.gz
uscxml-2b9e5d72a31c5060a443a0535d2d139326c51f04.tar.bz2
Fixed issue109
Diffstat (limited to 'src')
-rw-r--r--src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp b/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp
index 890b8cf..33255db 100644
--- a/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp
+++ b/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp
@@ -554,7 +554,27 @@ void LuaDataModel::assign(const std::string& location, const Data& data, const s
}
}
if (field.second) {
- value[strTo<long>(field.first)] = lua;
+ if (field.first.length() == 0) {
+ ERROR_EXECUTION_THROW("Subscript operator is empty");
+ }
+
+ if (!isNumeric(field.first.c_str(), 10) && field.first[0] != '"' && field.first[0] != '\'') {
+ // evaluate subscript as variable
+ Data subscript = evalAsData(field.first);
+ if (subscript.atom.length() > 0) {
+ field.first = subscript.atom;
+ } else {
+ ERROR_EXECUTION_THROW("Evaluated subscript operator '" + subscript.asJSON() + "' is invalid");
+ }
+ }
+
+ if (isNumeric(field.first.c_str(), 10)) {
+ // numeric array subscript
+ value[strTo<long>(field.first)] = lua;
+ } else {
+ // string array subscript
+ value[field.first] = lua;
+ }
} else {
value[field.first] = lua;
}