summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStefan Radomski <github@mintwerk.de>2017-05-19 09:42:36 (GMT)
committerStefan Radomski <github@mintwerk.de>2017-05-19 09:42:36 (GMT)
commit487761485fea0ddd7e08263e01e40156798db57a (patch)
tree8f6c59422aa37572ac248eeaab98810375c2fe87 /src
parent747781cbebe22efb4f2efb8f3269320962791914 (diff)
downloaduscxml-487761485fea0ddd7e08263e01e40156798db57a.zip
uscxml-487761485fea0ddd7e08263e01e40156798db57a.tar.gz
uscxml-487761485fea0ddd7e08263e01e40156798db57a.tar.bz2
Fixed issue 134 with remote scripts
Diffstat (limited to 'src')
-rw-r--r--src/uscxml/interpreter/BasicContentExecutor.cpp2
-rw-r--r--src/uscxml/interpreter/InterpreterImpl.cpp23
2 files changed, 24 insertions, 1 deletions
diff --git a/src/uscxml/interpreter/BasicContentExecutor.cpp b/src/uscxml/interpreter/BasicContentExecutor.cpp
index 9796c4c..696b575 100644
--- a/src/uscxml/interpreter/BasicContentExecutor.cpp
+++ b/src/uscxml/interpreter/BasicContentExecutor.cpp
@@ -289,7 +289,7 @@ void BasicContentExecutor::processLog(XERCESC_NS::DOMElement* content) {
}
void BasicContentExecutor::processScript(XERCESC_NS::DOMElement* content) {
- // download as necessary
+ // contents were already downloaded in setupDOM, see to SCXML rec 5.8
std::string scriptContent(X(content->getTextContent()));
_callbacks->eval(scriptContent);
diff --git a/src/uscxml/interpreter/InterpreterImpl.cpp b/src/uscxml/interpreter/InterpreterImpl.cpp
index 60448f9..f7a46fc 100644
--- a/src/uscxml/interpreter/InterpreterImpl.cpp
+++ b/src/uscxml/interpreter/InterpreterImpl.cpp
@@ -295,6 +295,29 @@ SCXML_STOP_SEARCH:
_name = _baseURL.pathComponents().back();
}
+ // download all script, see issue 134
+ std::list<DOMElement*> scripts = DOMUtils::filterChildElements(_xmlPrefix + "script", _scxml, true);
+ for (auto script : scripts) {
+ if (HAS_ATTR(script, kXMLCharSource)) {
+ std::string src = ATTR(script, kXMLCharSource);
+ std::string contents;
+ if (src.size() > 0) {
+ URL url(src);
+ if (!url.isAbsolute()) {
+ url = URL::resolve(url, _baseURL);
+ }
+ contents = url.getInContent();
+ } else {
+ ERROR_COMMUNICATION2(exc, "Empty source attribute", script);
+ throw exc;
+ }
+
+ XERCESC_NS::DOMText* scriptText = _document->createTextNode(X(contents));
+ XERCESC_NS::DOMNode* newNode = _document->importNode(scriptText, true);
+ script->appendChild(newNode);
+ }
+ }
+
_binding = (HAS_ATTR(_scxml, kXMLCharBinding) && iequals(ATTR(_scxml, kXMLCharBinding), "late") ? LATE : EARLY);
}