summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdwin Mons <edwin.mons@isode.com>2019-07-22 08:54:55 (GMT)
committerEdwin Mons <edwin.mons@isode.com>2019-07-22 10:13:33 (GMT)
commitf6fb85ba98fdd6601c4b8323c51c8367ccc4b52e (patch)
tree16f37c7ad860a527aac7e29e4b9d7e61bf1b635f /Swiften/Parser/LibXMLParser.cpp
parentf4b6bfbf4c1573e9914185e2ef170f47838ea11a (diff)
downloadswift-f6fb85ba98fdd6601c4b8323c51c8367ccc4b52e.zip
swift-f6fb85ba98fdd6601c4b8323c51c8367ccc4b52e.tar.bz2
Signal namespace declarations to ParserClients
Prior to calling handleStartElement, the ParserClient handleNamespaceDeclaration will fire for each namespace declared on the element. Test-Information: Unit tests pass on Debian 9 for both expat and libxml2 Change-Id: Ic42e83aee83edfbb2aa5c971997808eb6e133223
Diffstat (limited to 'Swiften/Parser/LibXMLParser.cpp')
-rw-r--r--Swiften/Parser/LibXMLParser.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/Swiften/Parser/LibXMLParser.cpp b/Swiften/Parser/LibXMLParser.cpp
index c9f3a07..192f44b 100644
--- a/Swiften/Parser/LibXMLParser.cpp
+++ b/Swiften/Parser/LibXMLParser.cpp
@@ -24,7 +24,7 @@ struct LibXMLParser::Private {
24 xmlParserCtxtPtr context_; 24 xmlParserCtxtPtr context_;
25}; 25};
26 26
27static void handleStartElement(void* parser, const xmlChar* name, const xmlChar*, const xmlChar* xmlns, int, const xmlChar**, int nbAttributes, int nbDefaulted, const xmlChar ** attributes) { 27static void handleStartElement(void* parser, const xmlChar* name, const xmlChar*, const xmlChar* xmlns, int nbNamespaces, const xmlChar** namespaces, int nbAttributes, int nbDefaulted, const xmlChar ** attributes) {
28 AttributeMap attributeValues; 28 AttributeMap attributeValues;
29 if (nbDefaulted != 0) { 29 if (nbDefaulted != 0) {
30 // Just because i don't understand what this means yet :-) 30 // Just because i don't understand what this means yet :-)
@@ -42,6 +42,11 @@ static void handleStartElement(void* parser, const xmlChar* name, const xmlChar*
42 std::string(reinterpret_cast<const char*>(attributes[i+3]), 42 std::string(reinterpret_cast<const char*>(attributes[i+3]),
43 static_cast<size_t>(attributes[i+4]-attributes[i+3]))); 43 static_cast<size_t>(attributes[i+4]-attributes[i+3])));
44 } 44 }
45 for (auto i = 0; i < nbNamespaces * 2; i += 2) {
46 const auto prefix = namespaces[i] ? std::string(reinterpret_cast<const char*>(namespaces[i])) : "";
47 const auto uri = std::string(reinterpret_cast<const char*>(namespaces[i + 1]));
48 static_cast<XMLParser*>(parser)->getClient()->handleNamespaceDeclaration(prefix, uri);
49 }
45 static_cast<XMLParser*>(parser)->getClient()->handleStartElement(reinterpret_cast<const char*>(name), (xmlns ? reinterpret_cast<const char*>(xmlns) : std::string()), attributeValues); 50 static_cast<XMLParser*>(parser)->getClient()->handleStartElement(reinterpret_cast<const char*>(name), (xmlns ? reinterpret_cast<const char*>(xmlns) : std::string()), attributeValues);
46} 51}
47 52