Attachment #803028: The right version for bug #711180

View | Details | Raw Unified | Return to bug 711180
Collapse All | Expand All

(-)a/content/base/src/nsContentUtils.cpp (-1 / +13 lines)
Line     Link Here 
 Lines 658-674   nsresult Link Here 
658
nsContentUtils::Atob(const nsAString& aAsciiBase64String,
658
nsContentUtils::Atob(const nsAString& aAsciiBase64String,
659
                     nsAString& aBinaryData)
659
                     nsAString& aBinaryData)
660
{
660
{
661
  if (!Is8bit(aAsciiBase64String)) {
661
  if (!Is8bit(aAsciiBase64String)) {
662
    aBinaryData.Truncate();
662
    aBinaryData.Truncate();
663
    return NS_ERROR_DOM_INVALID_CHARACTER_ERR;
663
    return NS_ERROR_DOM_INVALID_CHARACTER_ERR;
664
  }
664
  }
665
665
666
  nsresult rv = Base64Decode(aAsciiBase64String, aBinaryData);
666
  const PRUnichar* start = aAsciiBase64String.BeginReading();
667
  const PRUnichar* end = aAsciiBase64String.EndReading();
668
  nsString trimmedString;
669
  if (!trimmedString.SetCapacity(aAsciiBase64String.Length(), fallible_t())) {
670
    return NS_ERROR_DOM_INVALID_CHARACTER_ERR;
671
  }
672
  while (start < end) {
673
    if (!nsContentUtils::IsHTMLWhitespace(*start)) {
674
      trimmedString.Append(*start);
675
    }
676
    start++;
677
  }
678
  nsresult rv = Base64Decode(trimmedString, aBinaryData);
667
  if (NS_FAILED(rv) && rv == NS_ERROR_INVALID_ARG) {
679
  if (NS_FAILED(rv) && rv == NS_ERROR_INVALID_ARG) {
668
    return NS_ERROR_DOM_INVALID_CHARACTER_ERR;
680
    return NS_ERROR_DOM_INVALID_CHARACTER_ERR;
669
  }
681
  }
670
  return rv;
682
  return rv;
671
}
683
}
672
684
673
bool
685
bool
674
nsContentUtils::IsAutocompleteEnabled(nsIDOMHTMLInputElement* aInput)
686
nsContentUtils::IsAutocompleteEnabled(nsIDOMHTMLInputElement* aInput)
(-)a/content/base/test/Makefile.in (+1 lines)
Line     Link Here 
 Lines 238-253   MOCHITEST_FILES_A = \ Link Here 
238
		test_domparser_null_char.html \
238
		test_domparser_null_char.html \
239
		test_bug811701.html \
239
		test_bug811701.html \
240
		test_bug811701.xhtml \
240
		test_bug811701.xhtml \
241
		test_bug820909.html \
241
		test_bug820909.html \
242
		test_bug704063.html \
242
		test_bug704063.html \
243
		test_bug894874.html \
243
		test_bug894874.html \
244
		test_bug895974.html \
244
		test_bug895974.html \
245
		test_bug895239.html \
245
		test_bug895239.html \
246
		test_bug711180.html \
246
		$(NULL)
247
		$(NULL)
247
248
248
MOCHITEST_FILES_B = \
249
MOCHITEST_FILES_B = \
249
		test_bug459424.html \
250
		test_bug459424.html \
250
		bug461735-redirect1.sjs \
251
		bug461735-redirect1.sjs \
251
		bug461735-redirect2.sjs \
252
		bug461735-redirect2.sjs \
252
		bug461735-post-redirect.js \
253
		bug461735-post-redirect.js \
253
		test_bug513194.html \
254
		test_bug513194.html \
(-)a/content/base/test/test_bug711180.html (+25 lines)
Line     Link Here 
Line 0    Link Here 
1
<!DOCTYPE HTML>
2
<html>
3
<!--
4
https://bugzilla.mozilla.org/show_bug.cgi?id=711180
5
-->
6
<head>
7
  <title>Test for Bug 711180</title>
8
  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
9
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
10
</head>
11
<body>
12
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=711180">Mozilla Bug 711180</a>
13
<p id="display"></p>
14
<div id="content" style="display: none">
15
</div>
16
<pre id="test">
17
<script class="testbody" type="text/javascript">
18
19
/** Test for Bug 711180 **/
20
is(atob("aQ=="), atob("\t a\rQ\n=\f="), "Base64 space removal");
21
22
</script>
23
</pre>
24
</body>
25
</html>
(-)a/dom/imptests/failures/html/html/webappapis/atob/test_base64.html.json (-10 lines)
Line     Link Here 
 Lines 1-14    Link Here 
1
{
1
{
2
  "btoa(null) == \"bnVsbA==\"": true,
2
  "btoa(null) == \"bnVsbA==\"": true,
3
  "atob(\" abcd\") == \"i\u00b7\\x1d\"": true,
4
  "atob(\"abcd \") == \"i\u00b7\\x1d\"": true,
5
  "atob(\"ab\\tcd\") == \"i\u00b7\\x1d\"": true,
6
  "atob(\"ab\\ncd\") == \"i\u00b7\\x1d\"": true,
7
  "atob(\"ab\\fcd\") == \"i\u00b7\\x1d\"": true,
8
  "atob(\"ab\\rcd\") == \"i\u00b7\\x1d\"": true,
9
  "atob(\"ab cd\") == \"i\u00b7\\x1d\"": true,
10
  "atob(\"ab\\t\\n\\f\\r cd\") == \"i\u00b7\\x1d\"": true,
11
  "atob(\" \\t\\n\\f\\r ab\\t\\n\\f\\r cd\\t\\n\\f\\r \") == \"i\u00b7\\x1d\"": true,
12
  "atob(\"ab\\t\\n\\f\\r =\\t\\n\\f\\r =\\t\\n\\f\\r \") == \"i\"": true,
13
  "atob(null) == \"\u009e\u00e9e\"": true
3
  "atob(null) == \"\u009e\u00e9e\"": true
14
}
4
}

Return to bug 711180