1
0
mirror of https://github.com/roytam1/UXP.git synced 2026-05-26 13:58:49 +00:00
Files
UXP/parser/expat/09_include_xmlns.patch
T
Job Bautista a730f838c8 Issue #2889 - Part 5: Rewrite patches for Expat 2.7.3.
- Skipped the fix for BZ 569229 because I don't know where to apply that; the
  processInternalEntity method no longer exists. Hopefully the bug doesn't re-
  appear.
- Previous fixes for 3rd and 13th patches have been merged to their respective
  patches as well.
- 15th patch is now a fix for the 13th and 14th since somewhere between 2.6.4
  and 2.7.3 has made use of a debugging method we don't want to use as well as
  a new boolean method called parserBusy which got mistakenly excluded as an
  unused API while rewriting the 14th patch.
2026-01-14 00:03:54 +08:00

135 lines
4.7 KiB
Diff

diff --git a/lib/xmlparse.c b/lib/xmlparse.c
--- a/lib/xmlparse.c
+++ b/lib/xmlparse.c
@@ -3939,6 +3939,9 @@
int n;
XML_Char *uri;
int nPrefixes = 0;
+#ifdef MOZILLA_CLIENT /* Include xmlns attributes in attributes array */
+ int nXMLNSDeclarations = 0;
+#endif
BINDING *binding;
const XML_Char *localPart;
@@ -4096,7 +4099,13 @@
appAtts[attIndex], bindingsPtr);
if (result)
return result;
+#ifdef MOZILLA_CLIENT /* Include xmlns attributes in attributes array */
+ attIndex++;
+ nXMLNSDeclarations++;
+ (attId->name)[-1] = 3;
+#else
--attIndex;
+#endif
} else {
/* deal with other prefixed names later */
attIndex++;
@@ -4128,6 +4137,12 @@
da->value, bindingsPtr);
if (result)
return result;
+#ifdef MOZILLA_CLIENT /* Include xmlns attributes in attributes array */
+ (da->id->name)[-1] = 3;
+ nXMLNSDeclarations++;
+ appAtts[attIndex++] = da->id->name;
+ appAtts[attIndex++] = da->value;
+#endif
} else {
(da->id->name)[-1] = 2;
nPrefixes++;
@@ -4146,7 +4161,11 @@
/* expand prefixed attribute names, check for duplicates,
and clear flags that say whether attributes were specified */
i = 0;
+#ifdef MOZILLA_CLIENT /* Include xmlns attributes in attributes array */
+ if (nPrefixes || nXMLNSDeclarations) {
+#else
if (nPrefixes) {
+#endif
unsigned int j; /* hash table index */
unsigned long version = parser->m_nsAttsVersion;
@@ -4156,6 +4175,9 @@
}
unsigned int nsAttsSize = 1u << parser->m_nsAttsPower;
+#ifdef MOZILLA_CLIENT /* Include xmlns attributes in attributes array */
+ if (nPrefixes) {
+#endif
unsigned char oldNsAttsPower = parser->m_nsAttsPower;
/* size of hash table must be at least 2 * (# of prefixed attributes) */
if ((nPrefixes << 1)
@@ -4204,6 +4226,9 @@
parser->m_nsAtts[--j].version = version;
}
parser->m_nsAttsVersion = --version;
+#ifdef MOZILLA_CLIENT /* Include xmlns attributes in attributes array */
+ }
+#endif
/* expand prefixed names and check for duplicates */
for (; i < attIndex; i += 2) {
@@ -4303,10 +4328,61 @@
parser->m_nsAtts[j].hash = uriHash;
parser->m_nsAtts[j].uriName = s;
+#ifdef MOZILLA_CLIENT /* Include xmlns attributes in attributes array) */
+ if (! --nPrefixes && ! nXMLNSDeclarations) {
+#else
if (! --nPrefixes) {
+#endif
i += 2;
break;
}
+#ifdef MOZILLA_CLIENT /* Include xmlns attributes in attributes array */
+ } else if (s[-1] == 3) { /* xmlns attribute */
+ static const XML_Char xmlnsNamespace[] = {
+ ASCII_h, ASCII_t, ASCII_t, ASCII_p, ASCII_COLON, ASCII_SLASH, ASCII_SLASH,
+ ASCII_w, ASCII_w, ASCII_w, ASCII_PERIOD, ASCII_w, ASCII_3, ASCII_PERIOD,
+ ASCII_o, ASCII_r, ASCII_g, ASCII_SLASH, ASCII_2, ASCII_0, ASCII_0, ASCII_0,
+ ASCII_SLASH, ASCII_x, ASCII_m, ASCII_l, ASCII_n, ASCII_s, ASCII_SLASH, '\0'
+ };
+ static const XML_Char xmlnsPrefix[] = {
+ ASCII_x, ASCII_m, ASCII_l, ASCII_n, ASCII_s, '\0'
+ };
+
+ ((XML_Char *)s)[-1] = 0; /* clear flag */
+ if (! poolAppendString(&parser->m_tempPool, xmlnsNamespace)
+ || ! poolAppendChar(&parser->m_tempPool, parser->m_namespaceSeparator))
+ return XML_ERROR_NO_MEMORY;
+ s += sizeof(xmlnsPrefix) / sizeof(xmlnsPrefix[0]) - 1;
+ if (*s == XML_T(':')) {
+ ++s;
+ do { /* copies null terminator */
+ if (! poolAppendChar(&parser->m_tempPool, *s))
+ return XML_ERROR_NO_MEMORY;
+ } while (*s++);
+ if (parser->m_ns_triplets) { /* append namespace separator and prefix */
+ parser->m_tempPool.ptr[-1] = parser->m_namespaceSeparator;
+ if (! poolAppendString(&parser->m_tempPool, xmlnsPrefix)
+ || ! poolAppendChar(&parser->m_tempPool, '\0'))
+ return XML_ERROR_NO_MEMORY;
+ }
+ }
+ else {
+ /* xlmns attribute without a prefix. */
+ if (! poolAppendString(&parser->m_tempPool, xmlnsPrefix)
+ || ! poolAppendChar(&parser->m_tempPool, '\0'))
+ return XML_ERROR_NO_MEMORY;
+ }
+
+ /* store expanded name in attribute list */
+ s = poolStart(&parser->m_tempPool);
+ poolFinish(&parser->m_tempPool);
+ appAtts[i] = s;
+
+ if (! --nXMLNSDeclarations && ! nPrefixes) {
+ i += 2;
+ break;
+ }
+#endif
} else /* not prefixed */
((XML_Char *)s)[-1] = 0; /* clear flag */
}