Skip to content

Commit bad642b

Browse files
author
Shawn Roberts
committed
Unreviewed, rolling out r244821.
LayoutTests/imported/w3c: Causing Reverted changeset: "WebKit has too much of its own UTF-8 code and should rely more on ICU's UTF-8 support" https://bugs.webkit.org/show_bug.cgi?id=195535 https://trac.webkit.org/changeset/244821 Source/JavaScriptCore: Causing Reverted changeset: "WebKit has too much of its own UTF-8 code and should rely more on ICU's UTF-8 support" https://bugs.webkit.org/show_bug.cgi?id=195535 https://trac.webkit.org/changeset/244821 Source/WebCore: Causing Reverted changeset: "WebKit has too much of its own UTF-8 code and should rely more on ICU's UTF-8 support" https://bugs.webkit.org/show_bug.cgi?id=195535 https://trac.webkit.org/changeset/244821 Source/WebKit: Causing Reverted changeset: "WebKit has too much of its own UTF-8 code and should rely more on ICU's UTF-8 support" https://bugs.webkit.org/show_bug.cgi?id=195535 https://trac.webkit.org/changeset/244821 Source/WTF: Causing Reverted changeset: "WebKit has too much of its own UTF-8 code and should rely more on ICU's UTF-8 support" https://bugs.webkit.org/show_bug.cgi?id=195535 https://trac.webkit.org/changeset/244821 LayoutTests: Causing 4 Test262 failures on JSC Release and Debug Reverted changeset: "WebKit has too much of its own UTF-8 code and should rely more on ICU's UTF-8 support" https://bugs.webkit.org/show_bug.cgi?id=195535 https://trac.webkit.org/changeset/244821 Canonical link: https://commits.webkit.org/211640@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244827 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 33896c5 commit bad642b

29 files changed

Lines changed: 638 additions & 254 deletions

LayoutTests/ChangeLog

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
2019-05-01 Shawn Roberts <sroberts@apple.com>
2+
3+
Unreviewed, rolling out r244821.
4+
5+
Causing 4 Test262 failures on JSC Release and Debug
6+
7+
Reverted changeset:
8+
9+
"WebKit has too much of its own UTF-8 code and should rely
10+
more on ICU's UTF-8 support"
11+
https://bugs.webkit.org/show_bug.cgi?id=195535
12+
https://trac.webkit.org/changeset/244821
13+
114
2019-05-01 Youenn Fablet <youenn@apple.com>
215

316
Reject/throw when calling AudioContext methods on a stopped AudioContext

LayoutTests/css3/escape-dom-api-expected.txt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
44

55

66
PASS CSS.escape.length is 1
7-
PASS CSS.escape('\0') is ""
8-
PASS CSS.escape('a\0') is "a�"
9-
PASS CSS.escape('\0b') is "b"
10-
PASS CSS.escape('a\0b') is "a�b"
11-
PASS CSS.escape('') is ""
12-
PASS CSS.escape('a�') is "a�"
13-
PASS CSS.escape('b') is "b"
14-
PASS CSS.escape('a�b') is "a�b"
7+
PASS CSS.escape('\0') is "�"
8+
PASS CSS.escape('a\0') is "a�"
9+
PASS CSS.escape('\0b') is "�b"
10+
PASS CSS.escape('a\0b') is "a�b"
11+
PASS CSS.escape('�') is "�"
12+
PASS CSS.escape('a�') is "a�"
13+
PASS CSS.escape('�b') is "�b"
14+
PASS CSS.escape('a�b') is "a�b"
1515
PASS CSS.escape() threw exception TypeError: Not enough arguments.
1616
PASS CSS.escape(undefined) is "undefined"
1717
PASS CSS.escape(true) is "true"
@@ -53,16 +53,16 @@ PASS CSS.escape('-') is "\\-"
5353
PASS CSS.escape('-a') is "-a"
5454
PASS CSS.escape('--') is "--"
5555
PASS CSS.escape('--a') is "--a"
56-
PASS CSS.escape('€-_©') is "€-_©"
57-
PASS CSS.escape('€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ') is "\\7f €‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ"
58-
PASS CSS.escape(' ¡¢') is " ¡¢"
56+
PASS CSS.escape('€-_©') is "€-_©"
57+
PASS CSS.escape('€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ') is "\\7f €‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ"
58+
PASS CSS.escape(' ¡¢') is " ¡¢"
5959
PASS CSS.escape('a0123456789b') is "a0123456789b"
6060
PASS CSS.escape('abcdefghijklmnopqrstuvwxyz') is "abcdefghijklmnopqrstuvwxyz"
6161
PASS CSS.escape('ABCDEFGHIJKLMNOPQRSTUVWXYZ') is "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
6262
PASS CSS.escape(' !xy') is "\\ \\!xy"
63-
PASS CSS.escape('𝌆') is "𝌆"
64-
PASS CSS.escape('') is "\udf06"
65-
PASS CSS.escape('') is "\ud834"
63+
PASS CSS.escape('𝌆') is "𝌆"
64+
PASS CSS.escape('í¼†') is "\udf06"
65+
PASS CSS.escape('í ´') is "\ud834"
6666
PASS successfullyParsed is true
6767

6868
TEST COMPLETE

LayoutTests/fast/text/dangling-surrogates-expected.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ This tests verifies that the test tools can handle a dangling surrogate characte
33
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
44

55

6-
PASS danglingFirst is ""
7-
PASS danglingSecond is ""
6+
PASS danglingFirst is "í ƒ"
7+
PASS danglingSecond is "í°"
88
PASS successfullyParsed is true
99

1010
TEST COMPLETE

LayoutTests/imported/w3c/ChangeLog

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
2019-05-01 Shawn Roberts <sroberts@apple.com>
2+
3+
Unreviewed, rolling out r244821.
4+
5+
Causing
6+
7+
Reverted changeset:
8+
9+
"WebKit has too much of its own UTF-8 code and should rely
10+
more on ICU's UTF-8 support"
11+
https://bugs.webkit.org/show_bug.cgi?id=195535
12+
https://trac.webkit.org/changeset/244821
13+
114
2019-05-01 Youenn Fablet <youenn@apple.com>
215

316
Kept alive loaders should use the redirected request in case of redirections

LayoutTests/imported/w3c/web-platform-tests/encoding/textdecoder-utf16-surrogates-expected.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11

2-
FAIL utf-16le - lone surrogate lead assert_equals: expected "\ufffd" but got ""
2+
FAIL utf-16le - lone surrogate lead assert_equals: expected "\ufffd" but got "í €"
33
FAIL utf-16le - lone surrogate lead (fatal flag set) assert_throws: function "function () {
44
new TextDecoder(t.encoding, {fatal: true}).decode(new Uint8Array(t.input))
55
}" did not throw
6-
FAIL utf-16le - lone surrogate trail assert_equals: expected "\ufffd" but got ""
6+
FAIL utf-16le - lone surrogate trail assert_equals: expected "\ufffd" but got "í°€"
77
FAIL utf-16le - lone surrogate trail (fatal flag set) assert_throws: function "function () {
88
new TextDecoder(t.encoding, {fatal: true}).decode(new Uint8Array(t.input))
99
}" did not throw
10-
FAIL utf-16le - unmatched surrogate lead assert_equals: expected "\ufffd\0" but got "\0"
10+
FAIL utf-16le - unmatched surrogate lead assert_equals: expected "\ufffd\0" but got "í €\0"
1111
FAIL utf-16le - unmatched surrogate lead (fatal flag set) assert_throws: function "function () {
1212
new TextDecoder(t.encoding, {fatal: true}).decode(new Uint8Array(t.input))
1313
}" did not throw
14-
FAIL utf-16le - unmatched surrogate trail assert_equals: expected "\ufffd\0" but got "\0"
14+
FAIL utf-16le - unmatched surrogate trail assert_equals: expected "\ufffd\0" but got "í°€\0"
1515
FAIL utf-16le - unmatched surrogate trail (fatal flag set) assert_throws: function "function () {
1616
new TextDecoder(t.encoding, {fatal: true}).decode(new Uint8Array(t.input))
1717
}" did not throw
18-
FAIL utf-16le - swapped surrogate pair assert_equals: expected "\ufffd\ufffd" but got "��"
18+
FAIL utf-16le - swapped surrogate pair assert_equals: expected "\ufffd\ufffd" but got "í°€í €"
1919
FAIL utf-16le - swapped surrogate pair (fatal flag set) assert_throws: function "function () {
2020
new TextDecoder(t.encoding, {fatal: true}).decode(new Uint8Array(t.input))
2121
}" did not throw

LayoutTests/js/dom/webidl-type-mapping-expected.txt

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,48 +1009,48 @@ PASS converter.testEnforceRangeUnsignedShort = {valueOf:function(){throw new Err
10091009

10101010
converter.testUSVString = '!@#123ABCabc\x00\x80\xFF\r\n\t'
10111011
converter.testString = '!@#123ABCabc\x00\x80\xFF\r\n\t'
1012-
PASS converter.testUSVString is "!@#123ABCabc\u0000€ÿ\r\n\t"
1013-
PASS converter.testString is "!@#123ABCabc\u0000€ÿ\r\n\t"
1012+
PASS converter.testUSVString is "!@#123ABCabc\u0000€ÿ\r\n\t"
1013+
PASS converter.testString is "!@#123ABCabc\u0000€ÿ\r\n\t"
10141014
converter.testUSVString = '\u0100'
10151015
converter.testString = '\u0100'
1016-
PASS converter.testUSVString is "Ā"
1017-
PASS converter.testString is "Ā"
1016+
PASS converter.testUSVString is "Ā"
1017+
PASS converter.testString is "Ā"
10181018
PASS converter.testUSVString = {toString: function() { throw Error(); }} threw exception Error.
10191019
PASS converter.testString = {toString: function() { throw Error(); }} threw exception Error.
1020-
PASS converter.testUSVString is "Ā"
1021-
PASS converter.testString is "Ā"
1020+
PASS converter.testUSVString is "Ā"
1021+
PASS converter.testString is "Ā"
10221022
converter.testUSVString = "\ud800"
10231023
converter.testString = "\ud800"
1024-
PASS converter.testUSVString is ""
1024+
PASS converter.testUSVString is "�"
10251025
PASS converter.testString is "\ud800"
10261026
converter.testUSVString = "\udc00"
10271027
converter.testString = "\udc00"
1028-
PASS converter.testUSVString is ""
1028+
PASS converter.testUSVString is "�"
10291029
PASS converter.testString is "\udc00"
10301030
converter.testUSVString = "\ud800\u0000"
10311031
converter.testString = "\ud800\u0000"
1032-
PASS converter.testUSVString is "\u0000"
1032+
PASS converter.testUSVString is "�\u0000"
10331033
PASS converter.testString is "\ud800\u0000"
10341034
converter.testUSVString = "\udc00\u0000"
10351035
converter.testString = "\udc00\u0000"
1036-
PASS converter.testUSVString is "\u0000"
1036+
PASS converter.testUSVString is "�\u0000"
10371037
PASS converter.testString is "\udc00\u0000"
10381038
converter.testUSVString = "\udc00\ud800"
10391039
converter.testString = "\udc00\ud800"
1040-
PASS converter.testUSVString is "��"
1040+
PASS converter.testUSVString is "��"
10411041
PASS converter.testString is "\udc00\ud800"
1042-
converter.testUSVString = "𝄞"
1043-
converter.testString = "𝄞"
1044-
PASS converter.testUSVString is "𝄞"
1045-
PASS converter.testString is "𝄞"
1042+
converter.testUSVString = "𝄞"
1043+
converter.testString = "𝄞"
1044+
PASS converter.testUSVString is "𝄞"
1045+
PASS converter.testString is "𝄞"
10461046
converter.testByteString = '!@#123ABCabc\x00\x80\xFF\r\n\t'
1047-
PASS converter.testByteString is "!@#123ABCabc\u0000€ÿ\r\n\t"
1047+
PASS converter.testByteString is "!@#123ABCabc\u0000€ÿ\r\n\t"
10481048
converter.testByteString = '\u00FF'
1049-
PASS converter.testByteString is "ÿ"
1049+
PASS converter.testByteString is "ÿ"
10501050
PASS converter.testByteString = '\u0100' threw exception TypeError: Type error.
1051-
PASS converter.testByteString is "ÿ"
1051+
PASS converter.testByteString is "ÿ"
10521052
PASS converter.testByteString = {toString: function() { throw Error(); }} threw exception Error.
1053-
PASS converter.testByteString is "ÿ"
1053+
PASS converter.testByteString is "ÿ"
10541054
converter.testUSVString = true
10551055
converter.testString = true
10561056
converter.testByteString = true
@@ -1180,37 +1180,37 @@ PASS converter.testNodeRecord().hasOwnProperty('key2') is true
11801180
PASS 'key2' in converter.testNodeRecord() is true
11811181
PASS converter.testNodeRecord()['key2'] is document.documentElement
11821182
PASS converter.setTestNodeRecord({ key: 'hello' }) threw exception TypeError: Type error.
1183-
converter.setTestLongRecord({'': 1 })
1184-
PASS converter.testLongRecord()[''] is 1
1185-
converter.setTestNodeRecord({'': document })
1186-
PASS converter.testNodeRecord()[''] is document
1187-
converter.setTestLongRecord({'': 1 })
1188-
PASS converter.testLongRecord()[''] is 1
1189-
converter.setTestNodeRecord({'': document })
1190-
PASS converter.testNodeRecord()[''] is document
1191-
converter.setTestLongRecord({'': 1 })
1192-
PASS converter.testLongRecord()['\0'] is 1
1193-
converter.setTestNodeRecord({'': document })
1194-
PASS converter.testNodeRecord()['\0'] is document
1195-
converter.setTestLongRecord({'': 1 })
1196-
PASS converter.testLongRecord()['\0'] is 1
1197-
converter.setTestNodeRecord({'': document })
1198-
PASS converter.testNodeRecord()['\0'] is document
1199-
converter.setTestLongRecord({'��': 1 })
1200-
PASS converter.testLongRecord()['��'] is 1
1201-
converter.setTestNodeRecord({'��': document })
1202-
PASS converter.testNodeRecord()['��'] is document
1203-
converter.setTestLongRecord({'𝄞': 1 })
1204-
PASS converter.testLongRecord()['𝄞'] is 1
1205-
converter.setTestNodeRecord({'𝄞': document })
1206-
PASS converter.testNodeRecord()['𝄞'] is document
1183+
converter.setTestLongRecord({'í €': 1 })
1184+
PASS converter.testLongRecord()['í €'] is 1
1185+
converter.setTestNodeRecord({'í €': document })
1186+
PASS converter.testNodeRecord()['�'] is document
1187+
converter.setTestLongRecord({'í°€': 1 })
1188+
PASS converter.testLongRecord()['í°€'] is 1
1189+
converter.setTestNodeRecord({'í°€': document })
1190+
PASS converter.testNodeRecord()['�'] is document
1191+
converter.setTestLongRecord({'í €': 1 })
1192+
PASS converter.testLongRecord()['í €\0'] is 1
1193+
converter.setTestNodeRecord({'í €': document })
1194+
PASS converter.testNodeRecord()['�\0'] is document
1195+
converter.setTestLongRecord({'í°€': 1 })
1196+
PASS converter.testLongRecord()['í°€\0'] is 1
1197+
converter.setTestNodeRecord({'í°€': document })
1198+
PASS converter.testNodeRecord()['�\0'] is document
1199+
converter.setTestLongRecord({'í°€í €': 1 })
1200+
PASS converter.testLongRecord()['í°€í €'] is 1
1201+
converter.setTestNodeRecord({'í°€í €': document })
1202+
PASS converter.testNodeRecord()['��'] is document
1203+
converter.setTestLongRecord({'𝄞': 1 })
1204+
PASS converter.testLongRecord()['𝄞'] is 1
1205+
converter.setTestNodeRecord({'𝄞': document })
1206+
PASS converter.testNodeRecord()['𝄞'] is document
12071207
converter.setTestSequenceRecord({ key: ['value', 'other value'] })
12081208
PASS converter.testSequenceRecord().hasOwnProperty('key') is true
12091209
PASS 'key' in converter.testSequenceRecord() is true
12101210
PASS converter.testSequenceRecord()['key'] is ['value', 'other value']
1211-
PASS converter.setTestSequenceRecord({ 'Ā': ['value'] }) threw exception TypeError: Type error.
1212-
converter.setTestSequenceRecord({ 'ÿ': ['value'] })
1213-
PASS converter.testSequenceRecord()['ÿ'] is ['value']
1211+
PASS converter.setTestSequenceRecord({ 'Ā': ['value'] }) threw exception TypeError: Type error.
1212+
converter.setTestSequenceRecord({ 'ÿ': ['value'] })
1213+
PASS converter.testSequenceRecord()['ÿ'] is ['value']
12141214
PASS converter.testImpureNaNUnrestrictedDouble is NaN
12151215
PASS converter.testImpureNaN2UnrestrictedDouble is NaN
12161216
PASS converter.testQuietNaNUnrestrictedDouble is NaN

LayoutTests/js/invalid-utf8-in-syntax-error-expected.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Ensures that we correctly propagate the error message for lexer errors containin
33
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
44

55

6-
PASS ({f("�")}) threw exception SyntaxError: Unexpected string literal "". Expected a parameter pattern or a ')' in parameter list..
6+
PASS ({f("���")}) threw exception SyntaxError: Unexpected string literal "íº­". Expected a parameter pattern or a ')' in parameter list..
77
PASS successfullyParsed is true
88

99
TEST COMPLETE

LayoutTests/js/invalid-utf8-in-syntax-error.html

Lines changed: 0 additions & 10 deletions
This file was deleted.

Source/JavaScriptCore/API/JSClassRef.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@
3535
#include "ObjectPrototype.h"
3636
#include "JSCInlines.h"
3737
#include <wtf/text/StringHash.h>
38+
#include <wtf/unicode/UTF8Conversion.h>
3839

3940
using namespace JSC;
41+
using namespace WTF::Unicode;
4042

4143
const JSClassDefinition kJSClassDefinitionEmpty = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
4244

Source/JavaScriptCore/API/JSStringRef.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ JSStringRef JSStringCreateWithUTF8CString(const char* string)
4949
UChar* p = buffer.data();
5050
bool sourceIsAllASCII;
5151
const LChar* stringStart = reinterpret_cast<const LChar*>(string);
52-
if (convertUTF8ToUTF16(string, string + length, &p, p + length, &sourceIsAllASCII)) {
52+
if (conversionOK == convertUTF8ToUTF16(&string, string + length, &p, p + length, &sourceIsAllASCII)) {
5353
if (sourceIsAllASCII)
5454
return &OpaqueJSString::create(stringStart, length).leakRef();
5555
return &OpaqueJSString::create(buffer.data(), p - buffer.data()).leakRef();
@@ -102,18 +102,20 @@ size_t JSStringGetUTF8CString(JSStringRef string, char* buffer, size_t bufferSiz
102102
return 0;
103103

104104
char* destination = buffer;
105-
bool failed = false;
105+
ConversionResult result;
106106
if (string->is8Bit()) {
107107
const LChar* source = string->characters8();
108-
convertLatin1ToUTF8(&source, source + string->length(), &destination, destination + bufferSize - 1);
108+
result = convertLatin1ToUTF8(&source, source + string->length(), &destination, destination + bufferSize - 1);
109109
} else {
110110
const UChar* source = string->characters16();
111-
ConversionResult result = convertUTF16ToUTF8(&source, source + string->length(), &destination, destination + bufferSize - 1);
112-
failed = result != ConversionOK && result != TargetExhausted;
111+
result = convertUTF16ToUTF8(&source, source + string->length(), &destination, destination + bufferSize - 1, true);
113112
}
114113

115114
*destination++ = '\0';
116-
return failed ? 0 : destination - buffer;
115+
if (result != conversionOK && result != targetExhausted)
116+
return 0;
117+
118+
return destination - buffer;
117119
}
118120

119121
bool JSStringIsEqual(JSStringRef a, JSStringRef b)

0 commit comments

Comments
 (0)