Changeset 66336 in webkit
- Timestamp:
- Aug 29, 2010 1:46:08 PM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r66335 r66336 1 2010-08-29 Pawel Hajdan <phajdan.jr@chromium.org> 2 3 Reviewed by Darin Adler. 4 5 Fix libxml workarounds to work with recent versions of libxml. 6 I was testing locally with libxml2-2.7.6. 7 https://bugs.webkit.org/show_bug.cgi?id=30508 8 9 Based on patch by Philippe Normand <pnormand@igalia.com>. 10 11 This also fixes a Chromium bug: 12 http://code.google.com/p/chromium/issues/detail?id=29333 13 14 * dom/XMLDocumentParserLibxml2.cpp: 15 (WebCore::switchToUTF16): 16 (WebCore::XMLParserContext::createStringParser): 17 (WebCore::XMLDocumentParser::doWrite): 18 (WebCore::startDocumentHandler): 19 1 20 2010-08-29 Darin Adler <darin@apple.com> 2 21 -
trunk/WebCore/dom/XMLDocumentParserLibxml2.cpp
r66115 r66336 362 362 }; 363 363 364 static void switchToUTF16(xmlParserCtxtPtr ctxt) 365 { 366 // Hack around libxml2's lack of encoding overide support by manually 367 // resetting the encoding to UTF-16 before every chunk. Otherwise libxml 368 // will detect <?xml version="1.0" encoding="<encoding name>"?> blocks 369 // and switch encodings, causing the parse to fail. 370 const UChar BOM = 0xFEFF; 371 const unsigned char BOMHighByte = *reinterpret_cast<const unsigned char*>(&BOM); 372 xmlSwitchEncoding(ctxt, BOMHighByte == 0xFF ? XML_CHAR_ENCODING_UTF16LE : XML_CHAR_ENCODING_UTF16BE); 373 } 374 364 375 static bool shouldAllowExternalLoad(const KURL& url) 365 376 { … … 477 488 parser->_private = userData; 478 489 parser->replaceEntities = true; 479 const UChar BOM = 0xFEFF; 480 const unsigned char BOMHighByte = *reinterpret_cast<const unsigned char*>(&BOM); 481 xmlSwitchEncoding(parser, BOMHighByte == 0xFF ? XML_CHAR_ENCODING_UTF16LE : XML_CHAR_ENCODING_UTF16BE); 490 switchToUTF16(parser); 482 491 483 492 return adoptRef(new XMLParserContext(parser)); … … 646 655 RefPtr<XMLDocumentParser> protect(this); 647 656 648 // Hack around libxml2's lack of encoding overide support by manually 649 // resetting the encoding to UTF-16 before every chunk. Otherwise libxml 650 // will detect <?xml version="1.0" encoding="<encoding name>"?> blocks 651 // and switch encodings, causing the parse to fail. 652 const UChar BOM = 0xFEFF; 653 const unsigned char BOMHighByte = *reinterpret_cast<const unsigned char*>(&BOM); 654 xmlSwitchEncoding(context->context(), BOMHighByte == 0xFF ? XML_CHAR_ENCODING_UTF16LE : XML_CHAR_ENCODING_UTF16BE); 655 657 switchToUTF16(context->context()); 656 658 XMLDocumentParserScope scope(document()->docLoader()); 657 659 xmlParseChunk(context->context(), reinterpret_cast<const char*>(parseString.characters()), sizeof(UChar) * parseString.length(), 0); … … 1232 1234 { 1233 1235 xmlParserCtxt* ctxt = static_cast<xmlParserCtxt*>(closure); 1236 switchToUTF16(ctxt); 1234 1237 getParser(closure)->startDocument(ctxt->version, ctxt->encoding, ctxt->standalone); 1235 1238 xmlSAX2StartDocument(closure);
Note: See TracChangeset
for help on using the changeset viewer.