Changeset 202599 in webkit
- Timestamp:
- Jun 28, 2016 6:04:05 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r202597 r202599 1 2016-06-28 Jiewen Tan <jiewen_tan@apple.com> 2 3 Implement "replacement" codec 4 https://bugs.webkit.org/show_bug.cgi?id=159180 5 <rdar://problem/26015178> 6 7 Reviewed by Brent Fulgham. 8 9 * fast/encoding/char-decoding-expected.txt: 10 * fast/encoding/char-decoding.html: 11 * fast/encoding/char-encoding-expected.txt: 12 * fast/encoding/char-encoding.html: 13 * fast/encoding/charset-replacement-expected.txt: Added. 14 * fast/encoding/charset-replacement.html: Added. 15 1 16 2016-06-28 Michael Saboff <msaboff@apple.com> 2 17 -
trunk/LayoutTests/fast/encoding/char-decoding-expected.txt
r84473 r202599 191 191 PASS decode('UTF-16BE', '%D8%69%DE%D6') is 'U+D869/U+DED6' 192 192 PASS decode('unicodeFFFE', '%D8%69%DE%D6') is 'U+D869/U+DED6' 193 PASS decode('csiso2022kr', '%41%42%43%61%62%63%31%32%33%A0') is 'U+FFFD' 194 PASS decode('hz-gb-2312', '%41%42%43%61%62%63%31%32%33%A0') is 'U+FFFD' 195 PASS decode('iso-2022-cn', '%41%42%43%61%62%63%31%32%33%A0') is 'U+FFFD' 196 PASS decode('iso-2022-cn-ext', '%41%42%43%61%62%63%31%32%33%A0') is 'U+FFFD' 197 PASS decode('iso-2022-kr', '%41%42%43%61%62%63%31%32%33%A0') is 'U+FFFD' 193 198 PASS successfullyParsed is true 194 199 -
trunk/LayoutTests/fast/encoding/char-decoding.html
r155267 r202599 106 106 testDecode('unicodeFFFE', '%D8%69%DE%D6', 'U+D869/U+DED6'); 107 107 108 // Replacement encodings should decode as replacement (U+FFFD) then EOF 109 testDecode("csiso2022kr", "%41%42%43%61%62%63%31%32%33%A0", "U+FFFD"); 110 testDecode("hz-gb-2312", "%41%42%43%61%62%63%31%32%33%A0", "U+FFFD"); 111 testDecode("iso-2022-cn", "%41%42%43%61%62%63%31%32%33%A0", "U+FFFD"); 112 testDecode("iso-2022-cn-ext", "%41%42%43%61%62%63%31%32%33%A0", "U+FFFD"); 113 testDecode("iso-2022-kr", "%41%42%43%61%62%63%31%32%33%A0", "U+FFFD"); 114 108 115 </script> 109 116 <script src="../../resources/js-test-post.js"></script> -
trunk/LayoutTests/fast/encoding/char-encoding-expected.txt
r64817 r202599 17 17 PASS encode('GBK', 'U+22EF') is '%A1%AD' 18 18 PASS encode('GBK', 'U+301C') is '%A1%AB' 19 PASS encode('csiso2022kr', 'U+00A0') is '%C2%A0' 20 PASS encode('hz-gb-2312', 'U+00A0') is '%C2%A0' 21 PASS encode('iso-2022-cn', 'U+00A0') is '%C2%A0' 22 PASS encode('iso-2022-cn-ext', 'U+00A0') is '%C2%A0' 23 PASS encode('iso-2022-kr', 'U+00A0') is '%C2%A0' 19 24 PASS successfullyParsed is true 20 25 -
trunk/LayoutTests/fast/encoding/char-encoding.html
r155267 r202599 34 34 testEncode('GBK', 'U+22EF', '%A1%AD'); 35 35 testEncode('GBK', 'U+301C', '%A1%AB'); 36 // Replacement encodings - should encode as UTF-8 37 testEncode("csiso2022kr", "U+00A0", "%C2%A0"); 38 testEncode("hz-gb-2312", "U+00A0", "%C2%A0"); 39 testEncode("iso-2022-cn", "U+00A0", "%C2%A0"); 40 testEncode("iso-2022-cn-ext", "U+00A0", "%C2%A0"); 41 testEncode("iso-2022-kr", "U+00A0", "%C2%A0"); 36 42 37 43 // Turning on this test causes a download to occur. FIXME: A bug? -
trunk/LayoutTests/imported/w3c/ChangeLog
r202542 r202599 1 2016-06-28 Jiewen Tan <jiewen_tan@apple.com> 2 3 Implement "replacement" codec 4 https://bugs.webkit.org/show_bug.cgi?id=159180 5 <rdar://problem/26015178> 6 7 Reviewed by Brent Fulgham. 8 9 * web-platform-tests/dom/nodes/Document-characterSet-normalization-expected.txt: 10 1 11 2016-06-27 Youenn Fablet <youenn@apple.com> 2 12 -
trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Document-characterSet-normalization-expected.txt
r202471 r202599 639 639 PASS Name "EUC-KR" has label "windows-949" (inputEncoding) 640 640 PASS Name "EUC-KR" has label "windows-949" (charset) 641 FAIL Name "replacement" has label "csiso2022kr" (characterSet) assert_equals: expected "replacement" but got "ISO-2022-KR" 642 FAIL Name "replacement" has label "csiso2022kr" (inputEncoding) assert_equals: expected "replacement" but got "ISO-2022-KR" 643 FAIL Name "replacement" has label "csiso2022kr" (charset) assert_equals: expected "replacement" but got "ISO-2022-KR" 644 FAIL Name "replacement" has label "hz-gb-2312" (characterSet) assert_equals: expected "replacement" but got "HZ-GB-2312" 645 FAIL Name "replacement" has label "hz-gb-2312" (inputEncoding) assert_equals: expected "replacement" but got "HZ-GB-2312" 646 FAIL Name "replacement" has label "hz-gb-2312" (charset) assert_equals: expected "replacement" but got "HZ-GB-2312" 647 FAIL Name "replacement" has label "iso-2022-cn" (characterSet) assert_equals: expected "replacement" but got "ISO-2022-CN" 648 FAIL Name "replacement" has label "iso-2022-cn" (inputEncoding) assert_equals: expected "replacement" but got "ISO-2022-CN" 649 FAIL Name "replacement" has label "iso-2022-cn" (charset) assert_equals: expected "replacement" but got "ISO-2022-CN" 650 FAIL Name "replacement" has label "iso-2022-cn-ext" (characterSet) assert_equals: expected "replacement" but got "ISO-2022-CN-EXT" 651 FAIL Name "replacement" has label "iso-2022-cn-ext" (inputEncoding) assert_equals: expected "replacement" but got "ISO-2022-CN-EXT" 652 FAIL Name "replacement" has label "iso-2022-cn-ext" (charset) assert_equals: expected "replacement" but got "ISO-2022-CN-EXT" 653 FAIL Name "replacement" has label "iso-2022-kr" (characterSet) assert_equals: expected "replacement" but got "ISO-2022-KR" 654 FAIL Name "replacement" has label "iso-2022-kr" (inputEncoding) assert_equals: expected "replacement" but got "ISO-2022-KR" 655 FAIL Name "replacement" has label "iso-2022-kr" (charset) assert_equals: expected "replacement" but got "ISO-2022-KR" 641 PASS Name "replacement" has label "csiso2022kr" (characterSet) 642 PASS Name "replacement" has label "csiso2022kr" (inputEncoding) 643 PASS Name "replacement" has label "csiso2022kr" (charset) 644 PASS Name "replacement" has label "hz-gb-2312" (characterSet) 645 PASS Name "replacement" has label "hz-gb-2312" (inputEncoding) 646 PASS Name "replacement" has label "hz-gb-2312" (charset) 647 PASS Name "replacement" has label "iso-2022-cn" (characterSet) 648 PASS Name "replacement" has label "iso-2022-cn" (inputEncoding) 649 PASS Name "replacement" has label "iso-2022-cn" (charset) 650 PASS Name "replacement" has label "iso-2022-cn-ext" (characterSet) 651 PASS Name "replacement" has label "iso-2022-cn-ext" (inputEncoding) 652 PASS Name "replacement" has label "iso-2022-cn-ext" (charset) 653 PASS Name "replacement" has label "iso-2022-kr" (characterSet) 654 PASS Name "replacement" has label "iso-2022-kr" (inputEncoding) 655 PASS Name "replacement" has label "iso-2022-kr" (charset) 656 656 -
trunk/Source/WebCore/CMakeLists.txt
r202408 r202599 2379 2379 platform/text/TextCodecICU.cpp 2380 2380 platform/text/TextCodecLatin1.cpp 2381 platform/text/TextCodecReplacement.cpp 2381 2382 platform/text/TextCodecUTF16.cpp 2382 2383 platform/text/TextCodecUTF8.cpp -
trunk/Source/WebCore/ChangeLog
r202592 r202599 1 2016-06-28 Jiewen Tan <jiewen_tan@apple.com> 2 3 Implement "replacement" codec 4 https://bugs.webkit.org/show_bug.cgi?id=159180 5 <rdar://problem/26015178> 6 7 Reviewed by Brent Fulgham. 8 9 Test: fast/encoding/charset-replacement.html 10 11 Add support for "replacement" codec according to the spec: 12 https://encoding.spec.whatwg.org/#replacement 13 According to the spec, encoding labels {"csiso2022kr", "hz-gb-2312", "iso-2022-cn", 14 "iso-2022-cn-ext", "iso-2022-kr"} are used to conduct certain attacks that abuse 15 a mismatch between encodings supported on the server and the client. Therefore, 16 they are grouped under the "replacement" codec, which does the following things 17 to prevent those attacks. 18 1) Decode: terminates with a single U+FFFD. 19 2) Encode: treated as UTF-8. 20 21 Furthermore, the "replacement" codec is a specification convenience to group those 22 vulnerable encoding labels. Therefore, it should not be able to use directly. 23 24 This change is based on the following Blink changes: 25 https://codereview.chromium.org/265973003, and 26 https://codereview.chromium.org/261013007. 27 28 * CMakeLists.txt: 29 * WebCore.xcodeproj/project.pbxproj: 30 * platform/text/TextAllInOne.cpp: 31 * platform/text/TextCodecReplacement.cpp: Added. 32 (WebCore::TextCodecReplacement::create): 33 (WebCore::TextCodecReplacement::TextCodecReplacement): 34 (WebCore::TextCodecReplacement::registerEncodingNames): 35 (WebCore::TextCodecReplacement::registerCodecs): 36 (WebCore::TextCodecReplacement::decode): 37 * platform/text/TextCodecReplacement.h: Added. 38 * platform/text/TextEncoding.cpp: 39 (WebCore::TextEncoding::TextEncoding): 40 * platform/text/TextEncodingRegistry.cpp: 41 (WebCore::isReplacementEncoding): 42 (WebCore::extendTextCodecMaps): 43 * platform/text/TextEncodingRegistry.h: 44 1 45 2016-06-28 Dean Jackson <dino@apple.com> 2 46 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r202581 r202599 2332 2332 572A7F211C6E5719009C6149 /* SimulatedClick.h in Headers */ = {isa = PBXBuildFile; fileRef = 572A7F201C6E5719009C6149 /* SimulatedClick.h */; }; 2333 2333 572A7F231C6E5A66009C6149 /* SimulatedClick.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 572A7F221C6E5A66009C6149 /* SimulatedClick.cpp */; }; 2334 57EF5E601D20C83900171E60 /* TextCodecReplacement.h in Headers */ = {isa = PBXBuildFile; fileRef = 57EF5E5F1D20C83900171E60 /* TextCodecReplacement.h */; }; 2335 57EF5E621D20D28700171E60 /* TextCodecReplacement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 57EF5E611D20D28700171E60 /* TextCodecReplacement.cpp */; }; 2334 2336 580371611A66F00A00BAF519 /* ClipRect.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5803715F1A66F00A00BAF519 /* ClipRect.cpp */; }; 2335 2337 580371621A66F00A00BAF519 /* ClipRect.h in Headers */ = {isa = PBXBuildFile; fileRef = 580371601A66F00A00BAF519 /* ClipRect.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 9998 10000 572A7F201C6E5719009C6149 /* SimulatedClick.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimulatedClick.h; sourceTree = "<group>"; }; 9999 10001 572A7F221C6E5A66009C6149 /* SimulatedClick.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SimulatedClick.cpp; sourceTree = "<group>"; }; 10002 57EF5E5F1D20C83900171E60 /* TextCodecReplacement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextCodecReplacement.h; sourceTree = "<group>"; }; 10003 57EF5E611D20D28700171E60 /* TextCodecReplacement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextCodecReplacement.cpp; sourceTree = "<group>"; }; 10000 10004 5803715F1A66F00A00BAF519 /* ClipRect.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ClipRect.cpp; sourceTree = "<group>"; }; 10001 10005 580371601A66F00A00BAF519 /* ClipRect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClipRect.h; sourceTree = "<group>"; }; … … 22350 22354 B2C3DA0D0D006C1D00EF6F26 /* TextCodecLatin1.cpp */, 22351 22355 B2C3DA0E0D006C1D00EF6F26 /* TextCodecLatin1.h */, 22356 57EF5E611D20D28700171E60 /* TextCodecReplacement.cpp */, 22357 57EF5E5F1D20C83900171E60 /* TextCodecReplacement.h */, 22352 22358 B2C3DA0F0D006C1D00EF6F26 /* TextCodecUserDefined.cpp */, 22353 22359 B2C3DA100D006C1D00EF6F26 /* TextCodecUserDefined.h */, … … 27912 27918 BC3BE9990E9C1E5D00835588 /* RenderScrollbarTheme.h in Headers */, 27913 27919 458FE40A1589DF0B005609E6 /* RenderSearchField.h in Headers */, 27920 57EF5E601D20C83900171E60 /* TextCodecReplacement.h in Headers */, 27914 27921 0F11A54F0F39233100C37884 /* RenderSelectionInfo.h in Headers */, 27915 27922 AB247A6D0AFD6383003FA5FD /* RenderSlider.h in Headers */, … … 30190 30197 D359D789129CA2710006E5D2 /* HTMLDetailsElement.cpp in Sources */, 30191 30198 A8EA79F90A1916DF00A8EF5F /* HTMLDirectoryElement.cpp in Sources */, 30199 57EF5E621D20D28700171E60 /* TextCodecReplacement.cpp in Sources */, 30192 30200 A8EA7CB10A192B9C00A8EF5F /* HTMLDivElement.cpp in Sources */, 30193 30201 A8EA79F50A1916DF00A8EF5F /* HTMLDListElement.cpp in Sources */, -
trunk/Source/WebCore/platform/text/TextAllInOne.cpp
r165676 r202599 31 31 #include "TextCodecICU.cpp" 32 32 #include "TextCodecLatin1.cpp" 33 #include "TextCodecReplacement.cpp" 33 34 #include "TextCodecUTF16.cpp" 34 35 #include "TextCodecUTF8.cpp" -
trunk/Source/WebCore/platform/text/TextEncoding.cpp
r177280 r202599 48 48 , m_backslashAsCurrencySymbol(backslashAsCurrencySymbol()) 49 49 { 50 // Aliases are valid, but not "replacement" itself. 51 if (m_name && isReplacementEncoding(name)) 52 m_name = nullptr; 50 53 } 51 54 … … 54 57 , m_backslashAsCurrencySymbol(backslashAsCurrencySymbol()) 55 58 { 59 // Aliases are valid, but not "replacement" itself. 60 if (m_name && isReplacementEncoding(name)) 61 m_name = nullptr; 56 62 } 57 63 -
trunk/Source/WebCore/platform/text/TextEncodingRegistry.cpp
r195452 r202599 30 30 #include "TextCodecICU.h" 31 31 #include "TextCodecLatin1.h" 32 #include "TextCodecReplacement.h" 32 33 #include "TextCodecUserDefined.h" 33 34 #include "TextCodecUTF16.h" … … 268 269 } 269 270 271 bool isReplacementEncoding(const char* alias) 272 { 273 if (!alias) 274 return false; 275 276 if (strlen(alias) != 11) 277 return false; 278 279 return !strcasecmp(alias, "replacement"); 280 } 281 282 bool isReplacementEncoding(const String& alias) 283 { 284 return equalLettersIgnoringASCIICase(alias, "replacement"); 285 } 286 270 287 bool shouldShowBackslashAsCurrencySymbolIn(const char* canonicalEncodingName) 271 288 { … … 275 292 static void extendTextCodecMaps() 276 293 { 294 TextCodecReplacement::registerEncodingNames(addToTextEncodingNameMap); 295 TextCodecReplacement::registerCodecs(addToTextCodecMap); 296 277 297 TextCodecICU::registerEncodingNames(addToTextEncodingNameMap); 278 298 TextCodecICU::registerCodecs(addToTextCodecMap); -
trunk/Source/WebCore/platform/text/TextEncodingRegistry.h
r174757 r202599 47 47 bool isJapaneseEncoding(const char* canonicalEncodingName); 48 48 bool shouldShowBackslashAsCurrencySymbolIn(const char* canonicalEncodingName); 49 bool isReplacementEncoding(const char* alias); 50 bool isReplacementEncoding(const String& alias); 49 51 50 52 WEBCORE_EXPORT String defaultTextEncodingNameForSystemLanguage();
Note: See TracChangeset
for help on using the changeset viewer.