Re: [PATCH] msxml3: skip a possible BOM in doparse
Actually libxml2 is supposed to take care of that. Relevant code from xmlSwitchInputEncodingInt() : --- /* * Specific handling of the Byte Order Mark for * UTF-16 */ if ((handler->name != NULL) && (!strcmp(handler->name, "UTF-16LE") || !strcmp(handler->name, "UTF-16")) && (input->cur[0] == 0xFF) && (input->cur[1] == 0xFE)) { input->cur += 2; } if ((handler->name != NULL) && (!strcmp(handler->name, "UTF-16BE")) && (input->cur[0] == 0xFE) && (input->cur[1] == 0xFF)) { input->cur += 2; } --- So we need to figure out what's broken and where before skipping it on our side. On Fri, Dec 14, 2012 at 1:34 AM, Marcus Meissner <marcus(a)jet.franken.de>wrote:
Hi,
Issue encountered in Corel X4 installer. (see bug 11747), it gets a UTF16 document with BOM in front.
trace:msxml:domdoc_load (0x131d10)->({VT_BSTR: L"C:\\users\\marcus\\Temp\\{180A87F9-82B9-42A6-8F0E-3AC30A58AC8C}\\{5A51C731-A877-4C6E-8D51-CD16CDC46C9B}\\CorelDRAW Graphics Suite X4 Setup Files\\Setup.xml"}) trace:msxml:create_moniker_from_url L"C:\\users\\marcus\\Temp\\{180A87F9-82B9-42A6-8F0E-3AC30A58AC8C}\\{5A51C731-A877-4C6E-8D51-CD16CDC46C9B}\\CorelDRAW Graphics Suite X4 Setup Files\\Setup.xml" trace:msxml:bind_url 0x131570 trace:msxml:bsc_AddRef (0x138da0) ref=2 trace:msxml:bsc_QueryInterface interface {6d5140c1-7436-11ce-8034-00aa006009fa} not implemented trace:msxml:bsc_QueryInterface interface {aaa74ef9-8ee7-4659-88d9-f8c504da73cc} not implemented trace:msxml:bsc_OnStartBinding (0x138da0)->(ff 0x13a238) trace:msxml:bsc_QueryInterface interface {79eac9e4-baf9-11ce-8c82-00aa004ba90b} not implemented trace:msxml:bsc_OnDataAvailable (0x138da0)->(5 36572 0x33e908 0x33e8fc) trace:msxml:bsc_OnStopBinding (0x138da0)->(00000000 (null)) fixme:msxml:doparse start of xml is ffffffff fffffffe 3c 00 49 00 43
Bug is only fixed partially by this.
Ciao, Marcus --- dlls/msxml3/domdoc.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
diff --git a/dlls/msxml3/domdoc.c b/dlls/msxml3/domdoc.c index 49e6168..3504204 100644 --- a/dlls/msxml3/domdoc.c +++ b/dlls/msxml3/domdoc.c @@ -486,6 +486,16 @@ static xmlDocPtr doparse(domdoc* This, char const* ptr, int len, xmlCharEncoding sax_serror /* serror */ };
+ /* UTF-16 BOM at start of data */ + if ((len > 2) && (ptr[0] == (char)0xff) && (ptr[1] == (char)0xfe)) { + ptr += 2; + len -= 2; + if (encoding == XML_CHAR_ENCODING_NONE) + encoding = XML_CHAR_ENCODING_UTF16LE; + else + FIXME("Not changing xml encoding type from %d to XML_CHAR_ENCODING_UTF16LE.\n", encoding); + } + pctx = xmlCreateMemoryParserCtxt(ptr, len); if (!pctx) { -- 1.7.10.4
participants (1)
-
Nikolay Sivov