Fix handling of __Secure- and __Host- Cookie prefixes (#33717)

* Make checking for cookie prefixes case-insensitive

Cookie-Prefixes like "__Host-" and "__Secure-" are case insensitive
as per https://www.ietf.org/archive/id/draft-ietf-httpbis-rfc6265bis-15.html#name-storage-model.

This is tested by many WPT tests in cookies/prefix, for example
* cookies/prefix/__host.document-cookie.html
* cookies/prefix/__host.document-cookie.https.html

Since the implementation and the specification had diverged quite
significantly i also updated/added spec comments where appropriate
and slightly restructured code so its easier to follow. However,
the only change in behaviour is the prefix check described above.

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Update WPT expectations

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Remove unused import

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Fix cookie test cases

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Fix ignore cookie with __Host prefix and no specified path attribute

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Fix another cookie test case

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This commit is contained in:
Simon Wülker 2024-10-09 06:52:48 +02:00 committed by GitHub
parent a2b27012a5
commit ff6523c37e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 151 additions and 159 deletions

View file

@ -1,9 +0,0 @@
[__host.document-cookie.html]
[__HoSt: Non-secure origin: 'Path=/;']
expected: FAIL
[__HoSt: Non-secure origin: 'Path=/;domain=web-platform.test']
expected: FAIL
[__HoSt: Non-secure origin: 'Path=/;MaxAge=10']
expected: FAIL

View file

@ -1,15 +0,0 @@
[__host.document-cookie.https.html]
[__HoSt: Secure origin: Does not set 'Path=/;']
expected: FAIL
[__HoSt: Secure origin: Does not set 'Secure; Path=/; Domain=web-platform.test; ']
expected: FAIL
[__HoSt: Secure origin: Does not set 'Path=/;MaxAge=10']
expected: FAIL
[__HoSt: Secure origin: Does not set 'Secure; Path=/; Domain=web-platform.test; MaxAge=10']
expected: FAIL
[__HoSt: Secure origin: Does not set 'Secure; Path=/cookies/resources/list.py']
expected: FAIL

View file

@ -1,12 +0,0 @@
[__host.header.html]
[__HoSt: Non-secure origin: Does not set 'Path=/;']
expected: FAIL
[__HoSt: Non-secure origin: Does not set 'Path=/;domain=web-platform.test']
expected: FAIL
[__HoSt: Non-secure origin: Does not set 'Path=/;MaxAge=10']
expected: FAIL
[__HoSt: Non-secure origin: Does not set 'Path=/;HttpOnly']
expected: FAIL

View file

@ -1,21 +0,0 @@
[__host.header.https.html]
[__HoSt: Secure origin: Does not set 'Path=/;']
expected: FAIL
[__HoSt: Secure origin: Does not set 'Secure; Path=/; Domain=web-platform.test; ']
expected: FAIL
[__HoSt: Secure origin: Does not set 'Path=/;MaxAge=10']
expected: FAIL
[__HoSt: Secure origin: Does not set 'Secure; Path=/; Domain=web-platform.test; MaxAge=10']
expected: FAIL
[__HoSt: Secure origin: Does not set 'Path=/;HttpOnly']
expected: FAIL
[__HoSt: Secure origin: Does not set 'Secure; Path=/; Domain=web-platform.test; HttpOnly']
expected: FAIL
[__HoSt: Secure origin: Does not set 'Secure; Path=/cookies/resources/list.py']
expected: FAIL

View file

@ -1,9 +0,0 @@
[__secure.document-cookie.html]
[__SeCuRe: Non-secure origin: Should not set 'Path=/;']
expected: FAIL
[__SeCuRe: Non-secure origin: Should not set 'Path=/;MaxAge=10']
expected: FAIL
[__SeCuRe: Non-secure origin: Should not set 'Path=/;domain=web-platform.test']
expected: FAIL

View file

@ -1,9 +0,0 @@
[__secure.document-cookie.https.html]
[__SeCuRe: Secure origin: Should not set 'Path=/;']
expected: FAIL
[__SeCuRe: Secure origin: Should not set 'Path=/;MaxAge=10']
expected: FAIL
[__SeCuRe: Secure origin: Should not set 'Path=/;domain=web-platform.test']
expected: FAIL

View file

@ -1,12 +0,0 @@
[__secure.header.html]
[__SeCuRe: Non-secure origin: Should not set 'Path=/;']
expected: FAIL
[__SeCuRe: Non-secure origin: Should not set 'Path=/;domain=web-platform.test']
expected: FAIL
[__SeCuRe: Non-secure origin: Should not set 'Path=/;MaxAge=10']
expected: FAIL
[__SeCuRe: Non-secure origin: Should not set 'Path=/;HttpOnly']
expected: FAIL

View file

@ -1,12 +0,0 @@
[__secure.header.https.html]
[__SeCuRe: secure origin: Should not set 'Path=/;']
expected: FAIL
[__SeCuRe: secure origin: Should not set 'Path=/;MaxAge=10']
expected: FAIL
[__SeCuRe: secure origin: Should not set 'Path=/;HttpOnly']
expected: FAIL
[__SeCuRe: secure origin: Should not set 'Path=/;domain=not-web-platform.test']
expected: FAIL

View file

@ -1,18 +0,0 @@
[document-cookie.non-secure.html]
[__SeCuRe: Non-secure origin: 'Path=/;']
expected: FAIL
[__SeCuRe: Non-secure origin: 'Path=/;domain=web-platform.test']
expected: FAIL
[__SeCuRe: Non-secure origin: 'Path=/;MaxAge=10']
expected: FAIL
[__HoSt: Non-secure origin: 'Path=/; ']
expected: FAIL
[__HoSt: Non-secure origin: 'Path=/; domain=web-platform.test']
expected: FAIL
[__HoSt: Non-secure origin: 'Path=/; MaxAge=10']
expected: FAIL