mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 711180 - Ignore whitespace in atob. r=Ms2ger
This commit is contained in:
parent
d77b0369a3
commit
f79fad7a30
@ -665,7 +665,25 @@ nsContentUtils::Atob(const nsAString& aAsciiBase64String,
|
||||
return NS_ERROR_DOM_INVALID_CHARACTER_ERR;
|
||||
}
|
||||
|
||||
nsresult rv = Base64Decode(aAsciiBase64String, aBinaryData);
|
||||
const PRUnichar* start = aAsciiBase64String.BeginReading();
|
||||
const PRUnichar* iter = start;
|
||||
const PRUnichar* end = aAsciiBase64String.EndReading();
|
||||
nsString trimmedString;
|
||||
if (!trimmedString.SetCapacity(aAsciiBase64String.Length(), fallible_t())) {
|
||||
return NS_ERROR_DOM_INVALID_CHARACTER_ERR;
|
||||
}
|
||||
bool needTrimming = false;
|
||||
while (iter < end) {
|
||||
if (!nsContentUtils::IsHTMLWhitespace(*iter)) {
|
||||
if (!needTrimming) {
|
||||
needTrimming = true;
|
||||
trimmedString.Append(start, iter - start);
|
||||
}
|
||||
trimmedString.Append(*iter);
|
||||
}
|
||||
iter++;
|
||||
}
|
||||
nsresult rv = Base64Decode(trimmedString, aBinaryData);
|
||||
if (NS_FAILED(rv) && rv == NS_ERROR_INVALID_ARG) {
|
||||
return NS_ERROR_DOM_INVALID_CHARACTER_ERR;
|
||||
}
|
||||
|
25
content/base/test/test_bug711180.html
Normal file
25
content/base/test/test_bug711180.html
Normal file
@ -0,0 +1,25 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=711180
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 711180</title>
|
||||
<script type="text/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=711180">Mozilla Bug 711180</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
/** Test for Bug 711180 **/
|
||||
is(atob("aQ=="), atob("\t a\rQ\n=\f="), "Base64 space removal");
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user