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

Unified Diff: Source/modules/encoding/TextDecoder.cpp

Issue 261013007: Prevent direct use of "replacement" text encoding. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: MSVC fix Created 6 years, 7 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
Index: Source/modules/encoding/TextDecoder.cpp
diff --git a/Source/modules/encoding/TextDecoder.cpp b/Source/modules/encoding/TextDecoder.cpp
index dbd1eb3fbd9a7a6ecffab3fc70d1e75620c2acdc..2d84eb23c6d9fde95eca54fcb8d33f68a4cca3a1 100644
--- a/Source/modules/encoding/TextDecoder.cpp
+++ b/Source/modules/encoding/TextDecoder.cpp
@@ -34,6 +34,7 @@
#include "bindings/v8/ExceptionState.h"
#include "core/dom/ExceptionCode.h"
+#include "wtf/StringExtras.h"
#include "wtf/text/TextEncodingRegistry.h"
namespace WebCore {
@@ -43,7 +44,9 @@ TextDecoder* TextDecoder::create(const String& label, const Dictionary& options,
const String& encodingLabel = label.isNull() ? String("utf-8") : label;
WTF::TextEncoding encoding(encodingLabel);
- if (!encoding.isValid()) {
+ // The replacement encoding is not valid, but the Encoding API also
+ // rejects aliases of the replacement encoding.
+ if (!encoding.isValid() || !strcasecmp(encoding.name(), "replacement")) {
exceptionState.throwTypeError("The encoding label provided ('" + encodingLabel + "') is invalid.");
return 0;
}
« no previous file with comments | « LayoutTests/platform/win/fast/encoding/charset-replacement-expected.png ('k') | Source/wtf/text/TextCodecReplacement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698