Module: wine Branch: master Commit: b4c541b23a6131a3eb7c16ce1c484d127f8b5104 URL: https://gitlab.winehq.org/wine/wine/-/commit/b4c541b23a6131a3eb7c16ce1c484d1...
Author: Alexandre Julliard julliard@winehq.org Date: Sat Sep 30 13:39:09 2023 +0200
xml2: Import upstream release 2.11.5.
---
libs/xml2/encoding.c | 11 +++----- libs/xml2/include/libxml/xmlversion.h | 10 +++----- libs/xml2/parserInternals.c | 48 ++++++++++++++++++++++++----------- libs/xml2/valid.c | 3 +-- libs/xml2/xpath.c | 2 +- 5 files changed, 42 insertions(+), 32 deletions(-)
diff --git a/libs/xml2/encoding.c b/libs/xml2/encoding.c index 52bc15aca37..19ced4e4c6f 100644 --- a/libs/xml2/encoding.c +++ b/libs/xml2/encoding.c @@ -1988,22 +1988,18 @@ xmlUconvWrapper(uconv_t *cd, int toUnicode, unsigned char *out, int *outlen, ucnv_convertEx(cd->utf8, cd->uconv, &ucv_out, ucv_out + *outlen, &ucv_in, ucv_in + *inlen, cd->pivot_buf, &cd->pivot_source, &cd->pivot_target, - cd->pivot_buf + ICU_PIVOT_BUF_SIZE, 0, flush, &err); + cd->pivot_buf + ICU_PIVOT_BUF_SIZE, 0, 0, &err); } else { /* UTF-8 => UTF-16 => encoding */ ucnv_convertEx(cd->uconv, cd->utf8, &ucv_out, ucv_out + *outlen, &ucv_in, ucv_in + *inlen, cd->pivot_buf, &cd->pivot_source, &cd->pivot_target, - cd->pivot_buf + ICU_PIVOT_BUF_SIZE, 0, flush, &err); + cd->pivot_buf + ICU_PIVOT_BUF_SIZE, 0, 0, &err); } *inlen = ucv_in - (const char*) in; *outlen = ucv_out - (char *) out; - if (U_SUCCESS(err)) { - /* reset pivot buf if this is the last call for input (flush==TRUE) */ - if (flush) - cd->pivot_source = cd->pivot_target = cd->pivot_buf; + if (U_SUCCESS(err)) return 0; - } if (err == U_BUFFER_OVERFLOW_ERROR) return -1; if (err == U_INVALID_CHAR_FOUND || err == U_ILLEGAL_CHAR_FOUND) @@ -3830,4 +3826,3 @@ static int UTF8ToISO8859_16 (unsigned char* out, int *outlen,
#endif #endif - diff --git a/libs/xml2/include/libxml/xmlversion.h b/libs/xml2/include/libxml/xmlversion.h index e47c0860a87..0359ff59e43 100644 --- a/libs/xml2/include/libxml/xmlversion.h +++ b/libs/xml2/include/libxml/xmlversion.h @@ -29,21 +29,21 @@ XMLPUBFUN void xmlCheckVersion(int version); * * the version string like "1.2.3" */ -#define LIBXML_DOTTED_VERSION "2.11.4" +#define LIBXML_DOTTED_VERSION "2.11.5"
/** * LIBXML_VERSION: * * the version number: 1.2.3 value is 10203 */ -#define LIBXML_VERSION 21104 +#define LIBXML_VERSION 21105
/** * LIBXML_VERSION_STRING: * * the version number string, 1.2.3 value is "10203" */ -#define LIBXML_VERSION_STRING "21104" +#define LIBXML_VERSION_STRING "21105"
/** * LIBXML_VERSION_EXTRA: @@ -58,7 +58,7 @@ XMLPUBFUN void xmlCheckVersion(int version); * Macro to check that the libxml version in use is compatible with * the version the software has been compiled against */ -#define LIBXML_TEST_VERSION xmlCheckVersion(21104); +#define LIBXML_TEST_VERSION xmlCheckVersion(21105);
#ifndef VMS #if 0 @@ -522,5 +522,3 @@ XMLPUBFUN void xmlCheckVersion(int version); } #endif /* __cplusplus */ #endif - - diff --git a/libs/xml2/parserInternals.c b/libs/xml2/parserInternals.c index b92f6426553..c36bbfb62c6 100644 --- a/libs/xml2/parserInternals.c +++ b/libs/xml2/parserInternals.c @@ -1085,6 +1085,33 @@ xmlSwitchEncoding(xmlParserCtxtPtr ctxt, xmlCharEncoding enc) int ret;
if (ctxt == NULL) return(-1); + + /* + * FIXME: The BOM shouldn't be skipped here, but in the parsing code. + * + * Note that we look for a decoded UTF-8 BOM when switching to UTF-16. + * This is mostly useless but Webkit/Chromium relies on this behavior. + * See https://bugs.chromium.org/p/chromium/issues/detail?id=1451026 + */ + if ((ctxt->input != NULL) && + (ctxt->input->consumed == 0) && + (ctxt->input->cur != NULL) && + (ctxt->input->cur == ctxt->input->base) && + ((enc == XML_CHAR_ENCODING_UTF8) || + (enc == XML_CHAR_ENCODING_UTF16LE) || + (enc == XML_CHAR_ENCODING_UTF16BE))) { + /* + * Errata on XML-1.0 June 20 2001 + * Specific handling of the Byte Order Mark for + * UTF-8 + */ + if ((ctxt->input->cur[0] == 0xEF) && + (ctxt->input->cur[1] == 0xBB) && + (ctxt->input->cur[2] == 0xBF)) { + ctxt->input->cur += 3; + } + } + switch (enc) { case XML_CHAR_ENCODING_ERROR: __xmlErrEncoding(ctxt, XML_ERR_UNKNOWN_ENCODING, @@ -1097,18 +1124,6 @@ xmlSwitchEncoding(xmlParserCtxtPtr ctxt, xmlCharEncoding enc) case XML_CHAR_ENCODING_UTF8: /* default encoding, no conversion should be needed */ ctxt->charset = XML_CHAR_ENCODING_UTF8; - - /* - * Errata on XML-1.0 June 20 2001 - * Specific handling of the Byte Order Mark for - * UTF-8 - */ - if ((ctxt->input != NULL) && - (ctxt->input->cur[0] == 0xEF) && - (ctxt->input->cur[1] == 0xBB) && - (ctxt->input->cur[2] == 0xBF)) { - ctxt->input->cur += 3; - } return(0); case XML_CHAR_ENCODING_EBCDIC: handler = xmlDetectEBCDIC(ctxt->input); @@ -1200,8 +1215,8 @@ xmlSwitchInputEncoding(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
/* * Switching encodings during parsing is a really bad idea, - * but WebKit/Chromium switches from ISO-8859-1 to UTF-16 as soon as - * it finds Unicode characters with code points larger than 255. + * but Chromium can switch between ISO-8859-1 and UTF-16 before + * separate calls to xmlParseChunk. * * TODO: We should check whether the "raw" input buffer is empty and * convert the old content using the old encoder. @@ -1221,6 +1236,10 @@ xmlSwitchInputEncoding(xmlParserCtxtPtr ctxt, xmlParserInputPtr input, if (xmlBufIsEmpty(in->buffer) == 0) { size_t processed, use, consumed;
+ /* + * FIXME: The BOM shouldn't be skipped here, but in the parsing code. + */ + /* * Specific handling of the Byte Order Mark for * UTF-16 @@ -2228,4 +2247,3 @@ xmlKeepBlanksDefault(int val) { if (!val) xmlIndentTreeOutput = 1; return(old); } - diff --git a/libs/xml2/valid.c b/libs/xml2/valid.c index 06a7f382044..4a790d46902 100644 --- a/libs/xml2/valid.c +++ b/libs/xml2/valid.c @@ -1052,7 +1052,7 @@ xmlCopyDocElementContent(xmlDocPtr doc, xmlElementContentPtr cur) { if (cur->c1 != NULL) tmp->c1 = xmlCopyDocElementContent(doc,cur->c1); if (tmp->c1 != NULL) - tmp->c1->parent = ret; + tmp->c1->parent = tmp; prev = tmp; cur = cur->c2; } @@ -7153,4 +7153,3 @@ xmlValidGetValidElements(xmlNode *prev, xmlNode *next, const xmlChar **names, return(nb_valid_elements); } #endif /* LIBXML_VALID_ENABLED */ - diff --git a/libs/xml2/xpath.c b/libs/xml2/xpath.c index 8df7974f146..9c3a2acf6d5 100644 --- a/libs/xml2/xpath.c +++ b/libs/xml2/xpath.c @@ -3204,7 +3204,7 @@ xmlXPathFormatNumber(double number, char buffer[], int buffersize) /* Finally copy result back to caller */ size = strlen(work) + 1; if (size > buffersize) { - work[buffersize - 1] = 0; + /*work[buffersize - 1] = 0;*/ size = buffersize; } memmove(buffer, work, size);