Skip to content

Commit

Permalink
Compatibility: Ignore XML namespaces in tagnames to allow some weird …
Browse files Browse the repository at this point in the history
…clients.
  • Loading branch information
adedov committed May 13, 2015
1 parent c00945f commit 439732f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
12 changes: 10 additions & 2 deletions libiqxmlrpc/parser2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class Parser::Impl {
int sz = static_cast<int>(str.size());
#if (LIBXML_VERSION < 20703)
#define XML_PARSE_HUGE 0
#endif
#endif
reader = xmlReaderForMemory(buf2, sz, 0, 0, XML_PARSE_NONET | XML_PARSE_HUGE);
xmlTextReaderSetParserProp(reader, XML_PARSER_SUBST_ENTITIES, 0); // No XXE
}
Expand Down Expand Up @@ -185,7 +185,15 @@ class Parser::Impl {
std::string
tag_name()
{
return to_string(xmlTextReaderName(reader));
std::string rv = to_string(xmlTextReaderName(reader));

size_t pos = rv.find_first_of(":");
if (pos != std::string::npos)
{
rv.erase(0, pos+1);
}

return rv;
}

std::string
Expand Down
5 changes: 5 additions & 0 deletions tests/data/request-ns.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0"?>
<ns1:methodCall xmlns:ns1="http://example.com/ns1/">
<methodName>system.listMethods</methodName>
<params></params>
</ns1:methodCall>

0 comments on commit 439732f

Please sign in to comment.