mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 562137. Use the UTF-8 decoder to decode UTF-8 instead of just assuming that it really is UTF-8. r=sicking
This commit is contained in:
parent
99ce80bfab
commit
e19f8c4e1a
@ -1157,17 +1157,16 @@ nsXMLHttpRequest::ConvertBodyToText(nsAString& aOutBuffer)
|
||||
}
|
||||
}
|
||||
|
||||
// XXXbz is the charset ever "ASCII" as opposed to "us-ascii"?
|
||||
if (dataCharset.EqualsLiteral("ASCII")) {
|
||||
CopyASCIItoUTF16(mResponseBody, mResponseBodyUnicode);
|
||||
aOutBuffer = mResponseBodyUnicode;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (dataCharset.EqualsLiteral("UTF-8")) {
|
||||
CopyUTF8toUTF16(mResponseBody, mResponseBodyUnicode);
|
||||
aOutBuffer = mResponseBodyUnicode;
|
||||
return NS_OK;
|
||||
}
|
||||
// can't fast-path UTF-8 using CopyUTF8toUTF16, since above we assumed UTF-8
|
||||
// by default and CopyUTF8toUTF16 will stop if it encounters bytes that aren't
|
||||
// valid UTF-8. So we have to do the whole unicode decoder thing.
|
||||
|
||||
nsCOMPtr<nsICharsetConverterManager> ccm =
|
||||
do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
|
||||
|
@ -381,6 +381,8 @@ _TEST_FILES = test_bug5141.html \
|
||||
test_bug346485.html \
|
||||
test_bug560780.html \
|
||||
test_bug562652.html \
|
||||
test_bug562137.html \
|
||||
file_bug562137.txt \
|
||||
$(NULL)
|
||||
|
||||
# This test fails on the Mac for some reason
|
||||
|
1
content/base/test/file_bug562137.txt
Normal file
1
content/base/test/file_bug562137.txt
Normal file
@ -0,0 +1 @@
|
||||
I have nbsp
|
33
content/base/test/test_bug562137.html
Normal file
33
content/base/test/test_bug562137.html
Normal file
@ -0,0 +1,33 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=562137
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 562137</title>
|
||||
<script type="application/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=562137">Mozilla Bug 562137</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 562137 **/
|
||||
var myStr = "I\ufffdhave\ufffdnbsp\n";
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", "file_bug562137.txt", false);
|
||||
xhr.send();
|
||||
is(xhr.responseText, myStr);
|
||||
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user