Skip to content

Commit da64dee

Browse files
committed
Strip TAB & SPACE from name & value passed to CookieStore methods
https://bugs.webkit.org/show_bug.cgi?id=297118 Reviewed by NOBODY (OOPS!). The specification already covers set() and whatwg/cookiestore#281 will cover get(), getAll(), and delete() for consistency. subscribe() and unsubscribe() are not covered by this PR. They are not shipping and have various outstanding specification issues. This also removes an unused argument from CookieStore::MainThreadBridge::set. While using trim() I also discovered that the comments in Source/WTF/wtf/text/StringImpl.cpp were out-of-date so this updates those as well.
1 parent b33916a commit da64dee

17 files changed

+89
-43
lines changed

LayoutTests/imported/w3c/web-platform-tests/cookiestore/cookieStore_delete_arguments.https.any-expected.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ FAIL cookieStore.delete with positional empty name promise_test: Unhandled rejec
1616
FAIL cookieStore.delete with empty name in options promise_test: Unhandled rejection with value: object "TypeError: Type error"
1717
PASS cookieStore.delete with maximum cookie name size
1818
PASS cookieStore.delete with a __Host- prefix should not have a domain
19+
PASS cookieStore.delete with whitespace
1920

LayoutTests/imported/w3c/web-platform-tests/cookiestore/cookieStore_delete_arguments.https.any.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,3 +220,12 @@ promise_test(async testCase => {
220220
const cookie = await cookieStore.get('cookie-name');
221221
assert_equals(cookie, null);
222222
}, 'cookieStore.delete with a __Host- prefix should not have a domain');
223+
224+
promise_test(async testCase => {
225+
await cookieStore.set('cookie-name', 'cookie-value');
226+
testCase.add_cleanup(async () => {
227+
await cookieStore.delete('cookie-name');
228+
});
229+
const cookie = await cookieStore.delete(' cookie-name \t');
230+
assert_equals(cookie, undefined);
231+
}, 'cookieStore.delete with whitespace');

LayoutTests/imported/w3c/web-platform-tests/cookiestore/cookieStore_delete_arguments.https.any.serviceworker-expected.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ FAIL cookieStore.delete with positional empty name promise_test: Unhandled rejec
1616
FAIL cookieStore.delete with empty name in options promise_test: Unhandled rejection with value: object "TypeError: Type error"
1717
PASS cookieStore.delete with maximum cookie name size
1818
PASS cookieStore.delete with a __Host- prefix should not have a domain
19+
PASS cookieStore.delete with whitespace
1920

LayoutTests/imported/w3c/web-platform-tests/cookiestore/cookieStore_getAll_arguments.https.any-expected.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ PASS cookieStore.getAll with invalid url path in options
1010
PASS cookieStore.getAll with invalid url host in options
1111
PASS cookieStore.getAll with absolute url with fragment in options
1212
PASS cookieStore.getAll with absolute different url in options
13+
PASS cookieStore.getAll with whitespace
1314

LayoutTests/imported/w3c/web-platform-tests/cookiestore/cookieStore_getAll_arguments.https.any.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,14 @@ promise_test(async testCase => {
194194
assert_equals(cookies[0].value, 'cookie-value');
195195
}
196196
}, 'cookieStore.getAll with absolute different url in options');
197+
198+
promise_test(async testCase => {
199+
await cookieStore.set('cookie-name', 'cookie-value');
200+
testCase.add_cleanup(async () => {
201+
await cookieStore.delete('cookie-name');
202+
});
203+
const cookies = await cookieStore.getAll(' cookie-name \t');
204+
assert_equals(cookies.length, 1);
205+
assert_equals(cookies[0].name, 'cookie-name');
206+
assert_equals(cookies[0].value, 'cookie-value');
207+
}, 'cookieStore.getAll with whitespace');

LayoutTests/imported/w3c/web-platform-tests/cookiestore/cookieStore_getAll_arguments.https.any.serviceworker-expected.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ PASS cookieStore.getAll with same-origin url path in options
1010
PASS cookieStore.getAll with invalid url host in options
1111
PASS cookieStore.getAll with absolute url with fragment in options
1212
PASS cookieStore.getAll with absolute different url in options
13+
PASS cookieStore.getAll with whitespace
1314

LayoutTests/imported/w3c/web-platform-tests/cookiestore/cookieStore_get_arguments.https.any-expected.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ PASS cookieStore.get with invalid url path in options
1010
PASS cookieStore.get with invalid url host in options
1111
PASS cookieStore.get with absolute url with fragment in options
1212
PASS cookieStore.get with absolute different url in options
13+
PASS cookieStore.get with whitespace
1314

LayoutTests/imported/w3c/web-platform-tests/cookiestore/cookieStore_get_arguments.https.any.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,13 @@ promise_test(async testCase => {
142142
assert_equals(cookie.value, 'cookie-value');
143143
}
144144
}, 'cookieStore.get with absolute different url in options');
145+
146+
promise_test(async testCase => {
147+
await cookieStore.set('cookie-name', 'cookie-value');
148+
testCase.add_cleanup(async () => {
149+
await cookieStore.delete('cookie-name');
150+
});
151+
const cookie = await cookieStore.get(' cookie-name \t');
152+
assert_equals(cookie.name, 'cookie-name');
153+
assert_equals(cookie.value, 'cookie-value');
154+
}, 'cookieStore.get with whitespace');

LayoutTests/imported/w3c/web-platform-tests/cookiestore/cookieStore_get_arguments.https.any.serviceworker-expected.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ PASS cookieStore.get with same-origin url path in options
1010
PASS cookieStore.get with invalid url host in options
1111
PASS cookieStore.get with absolute url with fragment in options
1212
PASS cookieStore.get with absolute different url in options
13+
PASS cookieStore.get with whitespace
1314

LayoutTests/imported/w3c/web-platform-tests/cookiestore/cookieStore_set_arguments.https.any-expected.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ PASS cookieStore.set with get result
5151
PASS cookieStore.set checks if the path is too long
5252
PASS cookieStore.set checks if the domain is too long
5353
PASS cookieStore.set with a __Host- prefix should not have a domain
54-
FAIL cookieStore.set with whitespace only name and value assert_unreached: Should have rejected: undefined Reached unreachable code
55-
FAIL cookieStore.set with whitespace at begining or end assert_unreached: Should have rejected: undefined Reached unreachable code
54+
PASS cookieStore.set with whitespace only name and value
55+
PASS cookieStore.set with whitespace at begining or end
5656

0 commit comments

Comments
 (0)