diff options
author | Remko Tronçon <git@el-tramo.be> | 2012-04-24 18:22:30 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2012-04-24 18:23:11 (GMT) |
commit | 02c18de062510e8061598bf492c68cb5b0624831 (patch) | |
tree | 0d7fd23dad8e832fb8a15baf5e11295d44d4f9eb /3rdParty | |
parent | 98f0f0c5cee040d3b0df5ff4d695320b2f93da24 (diff) | |
download | swift-contrib-02c18de062510e8061598bf492c68cb5b0624831.zip swift-contrib-02c18de062510e8061598bf492c68cb5b0624831.tar.bz2 |
Make built-in expat ignore unbound prefix namespaces.
This works around a problem with broken servers relaying illegal
stanzas from broken clients. Obviously only works when using the
bundled Expat.
Note that the system OS X libXML also seems to behave this way.
Diffstat (limited to '3rdParty')
-rw-r--r-- | 3rdParty/Expat/ignore_unbound_prefix_namespaces.diff | 56 | ||||
-rwxr-xr-x | 3rdParty/Expat/src/xmlparse.c | 20 |
2 files changed, 67 insertions, 9 deletions
diff --git a/3rdParty/Expat/ignore_unbound_prefix_namespaces.diff b/3rdParty/Expat/ignore_unbound_prefix_namespaces.diff new file mode 100644 index 0000000..945e436 --- /dev/null +++ b/3rdParty/Expat/ignore_unbound_prefix_namespaces.diff @@ -0,0 +1,56 @@ +diff --git a/3rdParty/Expat/src/xmlparse.c b/3rdParty/Expat/src/xmlparse.c +index 94e31de..ad5add2 100755 +--- a/src/xmlparse.c ++++ b/src/xmlparse.c +@@ -2808,8 +2808,10 @@ storeAtts(XML_Parser parser, const ENCODING *enc, + ((XML_Char *)s)[-1] = 0; /* clear flag */ + id = (ATTRIBUTE_ID *)lookup(&dtd->attributeIds, s, 0); + b = id->prefix->binding; +- if (!b) +- return XML_ERROR_UNBOUND_PREFIX; ++ if (!b) { ++ //return XML_ERROR_UNBOUND_PREFIX; ++ continue; ++ } + + /* as we expand the name we also calculate its hash value */ + for (j = 0; j < b->uriLen; j++) { +@@ -2887,7 +2889,7 @@ storeAtts(XML_Parser parser, const ENCODING *enc, + return XML_ERROR_NONE; + + /* expand the element type name */ +- if (elementType->prefix) { ++ if (elementType->prefix && elementType->prefix->binding) { + binding = elementType->prefix->binding; + if (!binding) + return XML_ERROR_UNBOUND_PREFIX; +@@ -2983,10 +2985,10 @@ addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId, + && prefix->name[2] == XML_T(ASCII_l)) { + + /* Not allowed to bind xmlns */ +- if (prefix->name[3] == XML_T(ASCII_n) ++ /*if (prefix->name[3] == XML_T(ASCII_n) + && prefix->name[4] == XML_T(ASCII_s) + && prefix->name[5] == XML_T('\0')) +- return XML_ERROR_RESERVED_PREFIX_XMLNS; ++ return XML_ERROR_RESERVED_PREFIX_XMLNS;*/ + + if (prefix->name[3] == XML_T('\0')) + mustBeXML = XML_TRUE; +@@ -3003,12 +3005,12 @@ addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId, + isXML = isXML && len == xmlLen; + isXMLNS = isXMLNS && len == xmlnsLen; + +- if (mustBeXML != isXML) ++ /*if (mustBeXML != isXML) + return mustBeXML ? XML_ERROR_RESERVED_PREFIX_XML +- : XML_ERROR_RESERVED_NAMESPACE_URI; ++ : XML_ERROR_RESERVED_NAMESPACE_URI;*/ + +- if (isXMLNS) +- return XML_ERROR_RESERVED_NAMESPACE_URI; ++ /*if (isXMLNS) ++ return XML_ERROR_RESERVED_NAMESPACE_URI;*/ + + if (namespaceSeparator) + len++; diff --git a/3rdParty/Expat/src/xmlparse.c b/3rdParty/Expat/src/xmlparse.c index 94e31de..ad5add2 100755 --- a/3rdParty/Expat/src/xmlparse.c +++ b/3rdParty/Expat/src/xmlparse.c @@ -2808,8 +2808,10 @@ storeAtts(XML_Parser parser, const ENCODING *enc, ((XML_Char *)s)[-1] = 0; /* clear flag */ id = (ATTRIBUTE_ID *)lookup(&dtd->attributeIds, s, 0); b = id->prefix->binding; - if (!b) - return XML_ERROR_UNBOUND_PREFIX; + if (!b) { + //return XML_ERROR_UNBOUND_PREFIX; + continue; + } /* as we expand the name we also calculate its hash value */ for (j = 0; j < b->uriLen; j++) { @@ -2887,7 +2889,7 @@ storeAtts(XML_Parser parser, const ENCODING *enc, return XML_ERROR_NONE; /* expand the element type name */ - if (elementType->prefix) { + if (elementType->prefix && elementType->prefix->binding) { binding = elementType->prefix->binding; if (!binding) return XML_ERROR_UNBOUND_PREFIX; @@ -2983,10 +2985,10 @@ addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId, && prefix->name[2] == XML_T(ASCII_l)) { /* Not allowed to bind xmlns */ - if (prefix->name[3] == XML_T(ASCII_n) + /*if (prefix->name[3] == XML_T(ASCII_n) && prefix->name[4] == XML_T(ASCII_s) && prefix->name[5] == XML_T('\0')) - return XML_ERROR_RESERVED_PREFIX_XMLNS; + return XML_ERROR_RESERVED_PREFIX_XMLNS;*/ if (prefix->name[3] == XML_T('\0')) mustBeXML = XML_TRUE; @@ -3003,12 +3005,12 @@ addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId, isXML = isXML && len == xmlLen; isXMLNS = isXMLNS && len == xmlnsLen; - if (mustBeXML != isXML) + /*if (mustBeXML != isXML) return mustBeXML ? XML_ERROR_RESERVED_PREFIX_XML - : XML_ERROR_RESERVED_NAMESPACE_URI; + : XML_ERROR_RESERVED_NAMESPACE_URI;*/ - if (isXMLNS) - return XML_ERROR_RESERVED_NAMESPACE_URI; + /*if (isXMLNS) + return XML_ERROR_RESERVED_NAMESPACE_URI;*/ if (namespaceSeparator) len++; |