tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

09_include_xmlns.patch (5320B)


      1 diff --git a/expat/lib/xmlparse.c b/expat/lib/xmlparse.c
      2 --- a/expat/lib/xmlparse.c
      3 +++ b/expat/lib/xmlparse.c
      4 @@ -3458,6 +3458,9 @@ storeAtts(XML_Parser parser, const ENCOD
      5   int n;
      6   XML_Char *uri;
      7   int nPrefixes = 0;
      8 +/* BEGIN MOZILLA CHANGE (Include xmlns attributes in attributes array) */
      9 +  int nXMLNSDeclarations = 0;
     10 +/* END MOZILLA CHANGE */
     11   BINDING *binding;
     12   const XML_Char *localPart;
     13 
     14 @@ -3615,7 +3618,15 @@ storeAtts(XML_Parser parser, const ENCOD
     15                                            appAtts[attIndex], bindingsPtr);
     16         if (result)
     17           return result;
     18 +/* BEGIN MOZILLA CHANGE (Include xmlns attributes in attributes array) */
     19 +#if 0
     20         --attIndex;
     21 +#else
     22 +        attIndex++;
     23 +        nXMLNSDeclarations++;
     24 +        (attId->name)[-1] = 3;
     25 +#endif
     26 +/* END MOZILLA CHANGE */
     27       } else {
     28         /* deal with other prefixed names later */
     29         attIndex++;
     30 @@ -3647,6 +3658,12 @@ storeAtts(XML_Parser parser, const ENCOD
     31                                              da->value, bindingsPtr);
     32           if (result)
     33             return result;
     34 +/* BEGIN MOZILLA CHANGE (Include xmlns attributes in attributes array) */
     35 +          (da->id->name)[-1] = 3;
     36 +          nXMLNSDeclarations++;
     37 +          appAtts[attIndex++] = da->id->name;
     38 +          appAtts[attIndex++] = da->value;
     39 +/* END MOZILLA CHANGE */
     40         } else {
     41           (da->id->name)[-1] = 2;
     42           nPrefixes++;
     43 @@ -3665,7 +3682,13 @@ storeAtts(XML_Parser parser, const ENCOD
     44   /* expand prefixed attribute names, check for duplicates,
     45      and clear flags that say whether attributes were specified */
     46   i = 0;
     47 +/* BEGIN MOZILLA CHANGE (Include xmlns attributes in attributes array) */
     48 +#if 0
     49   if (nPrefixes) {
     50 +#else
     51 +  if (nPrefixes || nXMLNSDeclarations) {
     52 +#endif
     53 +/* END MOZILLA CHANGE */
     54     int j; /* hash table index */
     55     unsigned long version = parser->m_nsAttsVersion;
     56 
     57 @@ -3675,6 +3698,9 @@ storeAtts(XML_Parser parser, const ENCOD
     58     }
     59 
     60     unsigned int nsAttsSize = 1u << parser->m_nsAttsPower;
     61 +/* BEGIN MOZILLA CHANGE (Include xmlns attributes in attributes array) */
     62 +    if (nPrefixes) {
     63 +/* END MOZILLA CHANGE */
     64     unsigned char oldNsAttsPower = parser->m_nsAttsPower;
     65     /* size of hash table must be at least 2 * (# of prefixed attributes) */
     66     if ((nPrefixes << 1)
     67 @@ -3724,6 +3750,9 @@ storeAtts(XML_Parser parser, const ENCOD
     68         parser->m_nsAtts[--j].version = version;
     69     }
     70     parser->m_nsAttsVersion = --version;
     71 +/* BEGIN MOZILLA CHANGE (Include xmlns attributes in attributes array) */
     72 +    }
     73 +/* END MOZILLA CHANGE */
     74 
     75     /* expand prefixed names and check for duplicates */
     76     for (; i < attIndex; i += 2) {
     77 @@ -3823,10 +3852,63 @@ storeAtts(XML_Parser parser, const ENCOD
     78         parser->m_nsAtts[j].hash = uriHash;
     79         parser->m_nsAtts[j].uriName = s;
     80 
     81 +/* BEGIN MOZILLA CHANGE (Include xmlns attributes in attributes array) */
     82 +#if 0
     83         if (! --nPrefixes) {
     84 +#else
     85 +        if (! --nPrefixes && ! nXMLNSDeclarations) {
     86 +#endif
     87 +/* END MOZILLA CHANGE */
     88           i += 2;
     89           break;
     90         }
     91 +/* BEGIN MOZILLA CHANGE (Include xmlns attributes in attributes array) */
     92 +      } else if (s[-1] == 3) { /* xmlns attribute */
     93 +        static const XML_Char xmlnsNamespace[] = {
     94 +          ASCII_h, ASCII_t, ASCII_t, ASCII_p, ASCII_COLON, ASCII_SLASH, ASCII_SLASH,
     95 +          ASCII_w, ASCII_w, ASCII_w, ASCII_PERIOD, ASCII_w, ASCII_3, ASCII_PERIOD,
     96 +          ASCII_o, ASCII_r, ASCII_g, ASCII_SLASH, ASCII_2, ASCII_0, ASCII_0, ASCII_0,
     97 +          ASCII_SLASH, ASCII_x, ASCII_m, ASCII_l, ASCII_n, ASCII_s, ASCII_SLASH, '\0'
     98 +        };
     99 +        static const XML_Char xmlnsPrefix[] = {
    100 +          ASCII_x, ASCII_m, ASCII_l, ASCII_n, ASCII_s, '\0'
    101 +        };
    102 +
    103 +        ((XML_Char *)s)[-1] = 0;  /* clear flag */
    104 +        if (! poolAppendString(&parser->m_tempPool, xmlnsNamespace)
    105 +            || ! poolAppendChar(&parser->m_tempPool, parser->m_namespaceSeparator))
    106 +          return XML_ERROR_NO_MEMORY;
    107 +        s += sizeof(xmlnsPrefix) / sizeof(xmlnsPrefix[0]) - 1;
    108 +        if (*s == XML_T(':')) {
    109 +          ++s;
    110 +          do {  /* copies null terminator */
    111 +            if (! poolAppendChar(&parser->m_tempPool, *s))
    112 +              return XML_ERROR_NO_MEMORY;
    113 +          } while (*s++);
    114 +          if (parser->m_ns_triplets) { /* append namespace separator and prefix */
    115 +            parser->m_tempPool.ptr[-1] = parser->m_namespaceSeparator;
    116 +            if (! poolAppendString(&parser->m_tempPool, xmlnsPrefix)
    117 +                || ! poolAppendChar(&parser->m_tempPool, '\0'))
    118 +              return XML_ERROR_NO_MEMORY;
    119 +          }
    120 +        }
    121 +        else {
    122 +          /* xlmns attribute without a prefix. */
    123 +          if (! poolAppendString(&parser->m_tempPool, xmlnsPrefix)
    124 +              || ! poolAppendChar(&parser->m_tempPool, '\0'))
    125 +            return XML_ERROR_NO_MEMORY;
    126 +        }
    127 +
    128 +        /* store expanded name in attribute list */
    129 +        s = poolStart(&parser->m_tempPool);
    130 +        poolFinish(&parser->m_tempPool);
    131 +        appAtts[i] = s;
    132 +
    133 +        if (! --nXMLNSDeclarations && ! nPrefixes) {
    134 +          i += 2;
    135 +          break;
    136 +        }
    137 +/* END MOZILLA CHANGE */
    138       } else                     /* not prefixed */
    139         ((XML_Char *)s)[-1] = 0; /* clear flag */
    140     }