Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1549)

Unified Diff: Source/wtf/text/Base64.cpp

Issue 215833002: window.atob() returns wrong value when given a string container only white spaces (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/fast/dom/Window/atob-btoa-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/text/Base64.cpp
diff --git a/Source/wtf/text/Base64.cpp b/Source/wtf/text/Base64.cpp
index d40e292d4aecb5f12ebbf371cb4fb42177015945..20ac803e4279fc8fa2311b80357f1fc35802dbce 100644
--- a/Source/wtf/text/Base64.cpp
+++ b/Source/wtf/text/Base64.cpp
@@ -149,22 +149,34 @@ static inline bool base64DecodeInternal(const T* data, unsigned length, Vector<c
unsigned equalsSignCount = 0;
unsigned outLength = 0;
+ bool hadError = false;
for (unsigned idx = 0; idx < length; ++idx) {
unsigned ch = data[idx];
if (ch == '=') {
++equalsSignCount;
// There should never be more than 2 padding characters.
- if (policy == Base64ValidatePadding && equalsSignCount > 2)
- return false;
+ if (policy == Base64ValidatePadding && equalsSignCount > 2) {
+ hadError = true;
+ break;
+ }
} else if (('0' <= ch && ch <= '9') || ('A' <= ch && ch <= 'Z') || ('a' <= ch && ch <= 'z') || ch == '+' || ch == '/') {
- if (equalsSignCount)
- return false;
+ if (equalsSignCount) {
+ hadError = true;
+ break;
+ }
out[outLength++] = base64DecMap[ch];
} else if (!shouldIgnoreCharacter || !shouldIgnoreCharacter(ch)) {
- return false;
+ hadError = true;
+ break;
}
}
+ if (outLength < out.size())
+ out.shrink(outLength);
+
+ if (hadError)
+ return false;
+
if (!outLength)
return !equalsSignCount;
« no previous file with comments | « LayoutTests/fast/dom/Window/atob-btoa-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698