Advertisement
Guest User

Untitled

a guest
Sep 25th, 2013
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.98 KB | None | 0 0
  1. Index: srcs/parserInternals.c
  2. ===================================================================
  3. --- srcs/parserInternals.c  (revision 1054838)
  4. +++ srcs/parserInternals.c  (working copy)
  5. @@ -948,6 +948,8 @@
  6.  {
  7.      xmlCharEncodingHandlerPtr handler;
  8.  
  9. +    if (ctxt->forceUTF8 == 1) enc = XML_CHAR_ENCODING_UTF8;
  10. +
  11.      if (ctxt == NULL) return(-1);
  12.      switch (enc) {
  13.     case XML_CHAR_ENCODING_ERROR:
  14. @@ -1668,6 +1670,7 @@
  15.      ctxt->errNo = XML_ERR_OK;
  16.      ctxt->depth = 0;
  17.      ctxt->charset = XML_CHAR_ENCODING_UTF8;
  18. +    ctxt->forceUTF8 = 0;
  19.      ctxt->catalogs = NULL;
  20.      xmlInitNodeInfoSeq(&ctxt->node_seq);
  21.      return(0);
  22. Index: srcs/parser.c
  23. ===================================================================
  24. --- srcs/parser.c   (revision 1054838)
  25. +++ srcs/parser.c   (working copy)
  26. @@ -8929,6 +8929,15 @@
  27.     } else {
  28.         xmlFatalErr(ctxt, XML_ERR_STRING_NOT_STARTED, NULL);
  29.     }
  30. +
  31. +    if (ctxt->forceUTF8) {
  32. +        if (encoding != NULL)
  33. +        xmlFree((xmlChar *) encoding);
  34. +        if (ctxt->encoding != NULL)
  35. +        xmlFree((xmlChar *) ctxt->encoding);
  36. +        ctxt->encoding = xmlCharStrdup("UTF-8");
  37. +        return(ctxt->encoding);
  38. +    }
  39.     /*
  40.      * UTF-16 encoding stwich has already taken place at this stage,
  41.      * more over the little-endian/big-endian selection is already done
  42. @@ -13298,6 +13307,12 @@
  43.     ctxt->options |= XML_PARSE_COMPACT;
  44.          options -= XML_PARSE_COMPACT;
  45.      }
  46. +    if (options & XML_FORCE_UTF8) {
  47. +        ctxt->forceUTF8 = 1;
  48. +        options -= XML_FORCE_UTF8;
  49. +    } else {
  50. +        ctxt->forceUTF8 = 0;
  51. +    }
  52.      ctxt->linenumbers = 1;
  53.      return (options);
  54.  }
  55. Index: parser.h
  56. ===================================================================
  57. --- parser.h    (revision 1054838)
  58. +++ parser.h    (working copy)
  59. @@ -247,6 +247,7 @@
  60.      xmlParserInputPtr  entity;        /* used to check entities boundaries */
  61.      int                charset;       /* encoding of the in-memory content
  62.                          actually an xmlCharEncoding */
  63. +    int                forceUTF8;     /* ignoring encodings, using UTF8 for everywhere */
  64.      int                nodelen;       /* Those two fields are there to */
  65.      int                nodemem;       /* Speed up large node parsing */
  66.      int                pedantic;      /* signal pedantic warnings */
  67. @@ -1089,9 +1090,10 @@
  68.      XML_PARSE_NSCLEAN  = 1<<13,/* remove redundant namespaces declarations */
  69.      XML_PARSE_NOCDATA  = 1<<14,/* merge CDATA as text nodes */
  70.      XML_PARSE_NOXINCNODE= 1<<15,/* do not generate XINCLUDE START/END nodes */
  71. -    XML_PARSE_COMPACT   = 1<<16 /* compact small text nodes; no modification of
  72. +    XML_PARSE_COMPACT   = 1<<16, /* compact small text nodes; no modification of
  73.                                     the tree allowed afterwards (will possibly
  74.                    crash if you try to modify the tree) */
  75. +    XML_FORCE_UTF8      = 1<<17 /* force ignoring any charsets and use utf8 for everything */
  76.  } xmlParserOption;
  77.  
  78.  XMLPUBFUN void XMLCALL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement