Title: [152667] trunk/Source/WebCore
- Revision
- 152667
- Author
- [email protected]
- Date
- 2013-07-15 16:27:35 -0700 (Mon, 15 Jul 2013)
Log Message
xmlDocPtrForString shouldn't upconvert 8-bit string
https://bugs.webkit.org/show_bug.cgi?id=118693
Reviewed by Michael Saboff.
Merge https://chromium.googlesource.com/chromium/blink/+/5d9b240db74591c3689415c7b7c5180fadb379e9
Prior to this changeset, we were upconverting the entire XML document.
Let xmllib2 parse a document as iso-8859-1 when it's a 8-bit string.
* xml/parser/XMLDocumentParserLibxml2.cpp:
(WebCore::nativeEndianUTF16Encoding):
(WebCore::xmlDocPtrForString):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (152666 => 152667)
--- trunk/Source/WebCore/ChangeLog 2013-07-15 23:23:34 UTC (rev 152666)
+++ trunk/Source/WebCore/ChangeLog 2013-07-15 23:27:35 UTC (rev 152667)
@@ -1,3 +1,19 @@
+2013-07-15 Ryosuke Niwa <[email protected]>
+
+ xmlDocPtrForString shouldn't upconvert 8-bit string
+ https://bugs.webkit.org/show_bug.cgi?id=118693
+
+ Reviewed by Michael Saboff.
+
+ Merge https://chromium.googlesource.com/chromium/blink/+/5d9b240db74591c3689415c7b7c5180fadb379e9
+
+ Prior to this changeset, we were upconverting the entire XML document.
+ Let xmllib2 parse a document as iso-8859-1 when it's a 8-bit string.
+
+ * xml/parser/XMLDocumentParserLibxml2.cpp:
+ (WebCore::nativeEndianUTF16Encoding):
+ (WebCore::xmlDocPtrForString):
+
2013-07-15 Roger Fong <[email protected]>
Replace WKCACFTypes include with d3d9 include.
Modified: trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp (152666 => 152667)
--- trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp 2013-07-15 23:23:34 UTC (rev 152666)
+++ trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp 2013-07-15 23:27:35 UTC (rev 152667)
@@ -1388,6 +1388,13 @@
}
#if ENABLE(XSLT)
+static inline const char* nativeEndianUTF16Encoding()
+{
+ const UChar BOM = 0xFEFF;
+ const unsigned char BOMHighByte = *reinterpret_cast<const unsigned char*>(&BOM);
+ return BOMHighByte == 0xFF ? "UTF-16LE" : "UTF-16BE";
+}
+
void* xmlDocPtrForString(CachedResourceLoader* cachedResourceLoader, const String& source, const String& url)
{
if (source.isEmpty())
@@ -1396,16 +1403,14 @@
// Parse in a single chunk into an xmlDocPtr
// FIXME: Hook up error handlers so that a failure to parse the main document results in
// good error messages.
- const UChar BOM = 0xFEFF;
- const unsigned char BOMHighByte = *reinterpret_cast<const unsigned char*>(&BOM);
+ const bool is8Bit = source.is8Bit();
+ const char* characters = is8Bit ? reinterpret_cast<const char*>(source.characters8()) : reinterpret_cast<const char*>(source.characters16());
+ size_t sizeInBytes = source.length() * (is8Bit ? sizeof(LChar) : sizeof(UChar));
+ const char* encoding = is8Bit ? "iso-8859-1" : nativeEndianUTF16Encoding();
+
XMLDocumentParserScope scope(cachedResourceLoader, errorFunc, 0);
- xmlDocPtr sourceDoc = xmlReadMemory(reinterpret_cast<const char*>(source.characters()),
- source.length() * sizeof(UChar),
- url.latin1().data(),
- BOMHighByte == 0xFF ? "UTF-16LE" : "UTF-16BE",
- XSLT_PARSE_OPTIONS);
- return sourceDoc;
+ return xmlReadMemory(characters, sizeInBytes, url.latin1().data(), encoding, XSLT_PARSE_OPTIONS);
}
#endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes