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

Side by Side Diff: third_party/WebKit/Source/platform/text/TextEncodingDetectorTest.cpp

Issue 2253803003: Ignore 7-bit encodings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/text/TextEncodingDetector.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "platform/text/TextEncodingDetector.h"
6
7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "wtf/text/TextEncoding.h"
9
10 namespace blink {
11
12 TEST(TextResourceDecoderTest, RespectIso2022Jp)
13 {
14 // ISO-2022-JP is the only 7-bit encoding defined in WHATWG standard.
15 std::string iso2022jp = " \x1B""$BKL3$F;F|K\\%O%`%U%!%$%?!<%:$,%=%U%H%P%s%/$ H$N%W%l!<%*%U$r@)$7!\"";
16 WTF::TextEncoding encoding;
17 bool result = detectTextEncoding(iso2022jp.c_str(), iso2022jp.length(), null ptr, &encoding);
18 EXPECT_TRUE(result);
19 EXPECT_EQ(WTF::TextEncoding("ISO-2022-JP"), encoding);
20 }
21
22 TEST(TextResourceDecoderTest, Ignore7BitEncoding)
23 {
24 // 7-bit encodings except ISO-2022-JP are not supported by WHATWG.
25 // They should be detected as plain text (US-ASCII).
26 std::string hzGb2312 = " ~{\x54\x42\x31\x7D\x37\x22\x55\x39\x35\x3D\x3D\x71~ } abc";
27 WTF::TextEncoding encoding;
28 bool result = detectTextEncoding(hzGb2312.c_str(), hzGb2312.length(), nullpt r, &encoding);
29 EXPECT_TRUE(result);
30 EXPECT_EQ(WTF::TextEncoding("US-ASCII"), encoding);
31 }
32
33 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/text/TextEncodingDetector.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698