diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/uscxml/Interpreter.cpp | 13 | ||||
-rw-r--r-- | src/uscxml/Message.cpp | 18 | ||||
-rw-r--r-- | src/uscxml/server/HTTPServer.cpp | 4 |
3 files changed, 15 insertions, 20 deletions
diff --git a/src/uscxml/Interpreter.cpp b/src/uscxml/Interpreter.cpp index fa3e227..6334065 100644 --- a/src/uscxml/Interpreter.cpp +++ b/src/uscxml/Interpreter.cpp @@ -707,24 +707,11 @@ void InterpreterImpl::processDOMorText(const Arabica::DOM::Node<std::string>& el Arabica::SAX::InputSource<std::string> inputSource; inputSource.setByteStream(ssPtr); -// parser.setFeature(Arabica::SAX::FeatureNames<std::string>().external_general, true); - if (parser.parse(inputSource) && parser.getDocument()) { Document<std::string> doc = parser.getDocument(); dom = doc.getDocumentElement(); -#if 0 - Node<std::string> content = doc.getDocumentElement(); - assert(content.getNodeType() == Node_base::ELEMENT_NODE); - Node<std::string> container = doc.createElement("container"); - dom.replaceChild(container, content); - container.appendChild(content); -// std::cout << dom << std::endl; -#endif return; } else { - if (parser.errorsReported()) { - LOG(ERROR) << parser.errors(); - } text = srcContent.str(); return; } diff --git a/src/uscxml/Message.cpp b/src/uscxml/Message.cpp index b664fd1..bbd7f28 100644 --- a/src/uscxml/Message.cpp +++ b/src/uscxml/Message.cpp @@ -318,8 +318,7 @@ Data Data::fromXML(const std::string& xmlString) { Data Data::fromJSON(const std::string& jsonString) { Data data; - std::string trimmed = jsonString; - boost::trim(trimmed); + std::string trimmed = boost::trim_copy(jsonString); if (trimmed.length() == 0) return data; @@ -387,23 +386,29 @@ Data Data::fromJSON(const std::string& jsonString) { size_t currTok = 0; do { + // used for debugging // jsmntok_t t2 = t[currTok]; // std::string value = trimmed.substr(t[currTok].start, t[currTok].end - t[currTok].start); switch (t[currTok].type) { case JSMN_STRING: dataStack.back()->type = Data::VERBATIM; - case JSMN_PRIMITIVE: - dataStack.back()->atom = trimmed.substr(t[currTok].start, t[currTok].end - t[currTok].start); + case JSMN_PRIMITIVE: { + std::string value = trimmed.substr(t[currTok].start, t[currTok].end - t[currTok].start); + if (dataStack.back()->type == Data::VERBATIM) { + boost::replace_all(value, "\\\"", "\""); + } + dataStack.back()->atom = value; dataStack.pop_back(); currTok++; break; + } case JSMN_OBJECT: case JSMN_ARRAY: tokenStack.push_back(t[currTok]); currTok++; break; } - + // used for debugging // t2 = t[currTok]; // value = trimmed.substr(t[currTok].start, t[currTok].end - t[currTok].start); @@ -419,7 +424,8 @@ Data Data::fromJSON(const std::string& jsonString) { if (tokenStack.back().type == JSMN_OBJECT && (t[currTok].type == JSMN_PRIMITIVE || t[currTok].type == JSMN_STRING)) { // grab key and push new data - dataStack.push_back(&(dataStack.back()->compound[trimmed.substr(t[currTok].start, t[currTok].end - t[currTok].start)])); + std::string value = trimmed.substr(t[currTok].start, t[currTok].end - t[currTok].start); + dataStack.push_back(&(dataStack.back()->compound[value])); currTok++; } if (tokenStack.back().type == JSMN_ARRAY) { diff --git a/src/uscxml/server/HTTPServer.cpp b/src/uscxml/server/HTTPServer.cpp index d9fbc77..6c26811 100644 --- a/src/uscxml/server/HTTPServer.cpp +++ b/src/uscxml/server/HTTPServer.cpp @@ -440,7 +440,9 @@ void HTTPServer::processByMatchingServlet(const Request& request) { while(servletIter != _httpServlets.end()) { // is the servlet path a prefix of the actual path? std::string servletPath = "/" + servletIter->first; - if (iequals(actualPath.substr(0, servletPath.length()), servletPath) && // servlet path is a prefix + if (servletIter->first.length() == 0) { + matches.insert(std::make_pair(servletPath, servletIter->second)); // single servlet at root + } else if (iequals(actualPath.substr(0, servletPath.length()), servletPath) && // servlet path is a prefix iequals(actualPath.substr(servletPath.length(), 1), "/")) { // and next character is a '/' matches.insert(std::make_pair(servletPath, servletIter->second)); } |