Bug 1797235 - Implement WPT expectation. r=necko-reviewers,valentin

Differential Revision: https://phabricator.services.mozilla.com/D160638
This commit is contained in:
Tom Schuster 2022-11-04 16:24:54 +00:00
Родитель 98372c04f1
Коммит dbd87a19fb
4 изменённых файлов: 6 добавлений и 96 удалений

Просмотреть файл

@ -207,18 +207,15 @@ bool CookieCommons::CheckName(const CookieStruct& aCookieData) {
return aCookieData.name().FindCharInSet(illegalNameCharacters, 0) == -1;
}
bool CookieCommons::CheckHttpValue(const CookieStruct& aCookieData) {
bool CookieCommons::CheckValue(const CookieStruct& aCookieData) {
// reject cookie if value contains an RFC 6265 disallowed character - see
// https://bugzilla.mozilla.org/show_bug.cgi?id=1191423
// NOTE: this is not the full set of characters disallowed by 6265 - notably
// 0x09, 0x20, 0x22, 0x2C, 0x5C, and 0x7F are missing from this list. This is
// for parity with Chrome. This only applies to cookies set via the Set-Cookie
// header, as document.cookie is defined to be UTF-8. Hooray for
// symmetry!</sarcasm>
// 0x09, 0x20, 0x22, 0x2C, and 0x5C are missing from this list.
const char illegalCharacters[] = {
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x0A, 0x0B, 0x0C,
0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x3B, 0x00};
0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x3B, 0x7F, 0x00};
return aCookieData.value().FindCharInSet(illegalCharacters, 0) == -1;
}

Просмотреть файл

@ -90,7 +90,7 @@ class CookieCommons final {
static bool CheckName(const CookieStruct& aCookieData);
static bool CheckHttpValue(const CookieStruct& aCookieData);
static bool CheckValue(const CookieStruct& aCookieData);
static bool CheckCookiePermission(nsIChannel* aChannel,
CookieStruct& aCookieData);

Просмотреть файл

@ -1262,7 +1262,7 @@ bool CookieService::CanSetCookie(
return newCookie;
}
if (aFromHttp && !CookieCommons::CheckHttpValue(aCookieData)) {
if (!CookieCommons::CheckValue(aCookieData)) {
COOKIE_LOGFAILURE(SET_COOKIE, aHostURI, savedCookieHeader,
"invalid value character");
CookieLogging::LogMessageToConsole(
@ -2517,7 +2517,7 @@ bool CookieService::SetCookiesFromIPC(const nsACString& aBaseDomain,
return false;
}
if (aFromHttp && !CookieCommons::CheckHttpValue(cookieData)) {
if (!CookieCommons::CheckValue(cookieData)) {
return false;
}

Просмотреть файл

@ -1,91 +1,4 @@
[value-ctl.html]
[Cookie with %x1 in value is rejected.]
expected: FAIL
[Cookie with %x2 in value is rejected.]
expected: FAIL
[Cookie with %x3 in value is rejected.]
expected: FAIL
[Cookie with %x4 in value is rejected.]
expected: FAIL
[Cookie with %x5 in value is rejected.]
expected: FAIL
[Cookie with %x6 in value is rejected.]
expected: FAIL
[Cookie with %x7 in value is rejected.]
expected: FAIL
[Cookie with %x8 in value is rejected.]
expected: FAIL
[Cookie with %xb in value is rejected.]
expected: FAIL
[Cookie with %xc in value is rejected.]
expected: FAIL
[Cookie with %xe in value is rejected.]
expected: FAIL
[Cookie with %xf in value is rejected.]
expected: FAIL
[Cookie with %x10 in value is rejected.]
expected: FAIL
[Cookie with %x11 in value is rejected.]
expected: FAIL
[Cookie with %x12 in value is rejected.]
expected: FAIL
[Cookie with %x13 in value is rejected.]
expected: FAIL
[Cookie with %x14 in value is rejected.]
expected: FAIL
[Cookie with %x15 in value is rejected.]
expected: FAIL
[Cookie with %x16 in value is rejected.]
expected: FAIL
[Cookie with %x17 in value is rejected.]
expected: FAIL
[Cookie with %x18 in value is rejected.]
expected: FAIL
[Cookie with %x19 in value is rejected.]
expected: FAIL
[Cookie with %x1a in value is rejected.]
expected: FAIL
[Cookie with %x1b in value is rejected.]
expected: FAIL
[Cookie with %x1c in value is rejected.]
expected: FAIL
[Cookie with %x1d in value is rejected.]
expected: FAIL
[Cookie with %x1e in value is rejected.]
expected: FAIL
[Cookie with %x1f in value is rejected.]
expected: FAIL
[Cookie with %x7f in value is rejected.]
expected: FAIL
[Cookie with %x0 in value is rejected.]
expected: FAIL