From 91c81948221cac182e6f64a939983af2bb7a91b0 Mon Sep 17 00:00:00 2001 From: Stefan Radomski Date: Mon, 29 May 2017 15:45:06 +0200 Subject: Fixed issue 141 --- src/uscxml/debug/InterpreterIssue.cpp | 8 +++++++- src/uscxml/interpreter/InterpreterImpl.cpp | 1 + .../ecmascript/JavaScriptCore/JSCDataModel.cpp | 2 +- src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp | 2 +- test/src/test-validating.cpp | 18 +++++++++++++++++- 5 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/uscxml/debug/InterpreterIssue.cpp b/src/uscxml/debug/InterpreterIssue.cpp index a4d8841..346c0f6 100644 --- a/src/uscxml/debug/InterpreterIssue.cpp +++ b/src/uscxml/debug/InterpreterIssue.cpp @@ -147,10 +147,16 @@ std::list InterpreterIssue::forInterpreter(InterpreterImpl* in // some things we need to prepare first if (interpreter->_factory == NULL) interpreter->_factory = Factory::getInstance(); - interpreter->setupDOM(); std::list issues; + try { + interpreter->setupDOM(); + } catch(Event e) { + InterpreterIssue issue("Could not setup SCXML DOM: " + e.data.asJSON(), NULL, InterpreterIssue::USCXML_ISSUE_FATAL); + issues.push_back(issue); + } + if (!interpreter->_scxml) { InterpreterIssue issue("No SCXML element to be found", NULL, InterpreterIssue::USCXML_ISSUE_FATAL); issues.push_back(issue); diff --git a/src/uscxml/interpreter/InterpreterImpl.cpp b/src/uscxml/interpreter/InterpreterImpl.cpp index f7a46fc..bc8d2b9 100644 --- a/src/uscxml/interpreter/InterpreterImpl.cpp +++ b/src/uscxml/interpreter/InterpreterImpl.cpp @@ -315,6 +315,7 @@ SCXML_STOP_SEARCH: XERCESC_NS::DOMText* scriptText = _document->createTextNode(X(contents)); XERCESC_NS::DOMNode* newNode = _document->importNode(scriptText, true); script->appendChild(newNode); + script->removeAttribute(kXMLCharSource); // remove attribute for validation: see issue 141 } } diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp index 4203305..921f4cf 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp @@ -583,7 +583,7 @@ Data JSCDataModel::getValueAsData(const JSValueRef value) { char* buf = new char[maxSize]; JSStringGetUTF8CString(stringValue, buf, maxSize); std::string property(buf); - if (!isNumeric(property.c_str(), 10)) + if (!isInteger(property.c_str(), 10)) isArray = false; propertySet.insert(property); //JSStringRelease(stringValue); // JSPropertyNameArrayRelease does the job it seems diff --git a/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp b/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp index de3078b..4f78e7d 100644 --- a/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp +++ b/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp @@ -163,7 +163,7 @@ static luabridge::LuaRef getDataAsLua(lua_State* _luaState, const Data& data) { luaData = luabridge::newTable(_luaState); std::map::const_iterator compoundIter = data.compound.begin(); while(compoundIter != data.compound.end()) { - if (isNumeric(compoundIter->first.c_str(), 10) && strTo(compoundIter->first) > 0) { + if (isInteger(compoundIter->first.c_str(), 10) && strTo(compoundIter->first) > 0) { // it makes a difference whether we pass a numeric string or a proper number! luaData[strTo(compoundIter->first)] = getDataAsLua(_luaState, compoundIter->second); } else { diff --git a/test/src/test-validating.cpp b/test/src/test-validating.cpp index e69c07d..ae2a2f5 100644 --- a/test/src/test-validating.cpp +++ b/test/src/test-validating.cpp @@ -351,6 +351,22 @@ bool attributeConstraints() { } { + // source with src and child content, not allowed + const char* xml = + "" + " " + " " + "