Backed out 2 changesets (bug 1813469, bug 1797231) for causing failures related to TestCookie.BlockUnicode on windows. CLOSED TREE

Backed out changeset 89ccb90407c3 (bug 1797231)
Backed out changeset 7026b56af3d2 (bug 1813469)
This commit is contained in:
Iulian Moraru 2023-01-31 17:21:31 +02:00
parent 96480e22fb
commit 057b6edd3e
5 changed files with 2 additions and 103 deletions

View File

@ -11017,12 +11017,6 @@
value: false
mirror: always
# If true then any cookies containing unicode will be rejected
- name: network.cookie.blockUnicode
type: RelaxedAtomicBool
value: false
mirror: always
# If we should attempt to race the cache and network.
- name: network.http.rcwn.enabled
type: bool

View File

@ -204,19 +204,7 @@ bool CookieCommons::CheckName(const CookieStruct& aCookieData) {
0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,
0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x00};
const auto* start = aCookieData.name().BeginReading();
const auto* end = aCookieData.name().EndReading();
auto charFilter = [&](unsigned char c) {
if (StaticPrefs::network_cookie_blockUnicode() && c >= 0x80) {
return true;
}
return std::find(std::begin(illegalNameCharacters),
std::end(illegalNameCharacters),
c) != std::end(illegalNameCharacters);
};
return std::find_if(start, end, charFilter) == end;
return aCookieData.name().FindCharInSet(illegalNameCharacters, 0) == -1;
}
bool CookieCommons::CheckValue(const CookieStruct& aCookieData) {
@ -228,19 +216,7 @@ bool CookieCommons::CheckValue(const CookieStruct& aCookieData) {
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, 0x7F, 0x00};
const auto* start = aCookieData.value().BeginReading();
const auto* end = aCookieData.value().EndReading();
auto charFilter = [&](unsigned char c) {
if (StaticPrefs::network_cookie_blockUnicode() && c >= 0x80) {
return true;
}
return std::find(std::begin(illegalCharacters), std::end(illegalCharacters),
c) != std::end(illegalCharacters);
};
return std::find_if(start, end, charFilter) == end;
return aCookieData.value().FindCharInSet(illegalCharacters, 0) == -1;
}
// static

View File

@ -1154,24 +1154,6 @@ void CookieService::GetCookiesForURI(
aCookieList.Sort(CompareCookiesForSending());
}
static bool ContainsUnicodeChars(const nsCString& str) {
const auto* start = str.BeginReading();
const auto* end = str.EndReading();
return std::find_if(start, end, [](unsigned char c) { return c >= 0x80; }) !=
end;
}
static void RecordUnicodeTelemetry(const CookieStruct& cookieData) {
auto label = Telemetry::LABELS_NETWORK_COOKIE_UNICODE_BYTE::none;
if (ContainsUnicodeChars(cookieData.name())) {
label = Telemetry::LABELS_NETWORK_COOKIE_UNICODE_BYTE::unicodeName;
} else if (ContainsUnicodeChars(cookieData.value())) {
label = Telemetry::LABELS_NETWORK_COOKIE_UNICODE_BYTE::unicodeValue;
}
Telemetry::AccumulateCategorical(label);
}
// processes a single cookie, and returns true if there are more cookies
// to be processed
bool CookieService::CanSetCookie(
@ -1243,8 +1225,6 @@ bool CookieService::CanSetCookie(
return newCookie;
}
RecordUnicodeTelemetry(aCookieData);
if (!CookieCommons::CheckName(aCookieData)) {
COOKIE_LOGFAILURE(SET_COOKIE, aHostURI, savedCookieHeader,
"invalid name character");
@ -2552,8 +2532,6 @@ bool CookieService::SetCookiesFromIPC(const nsACString& aBaseDomain,
return false;
}
RecordUnicodeTelemetry(cookieData);
if (!CookieCommons::CheckName(cookieData)) {
return false;
}

View File

@ -1087,41 +1087,3 @@ TEST(TestCookie, HiddenPrefix)
GetACookie(cookieService, "http://hiddenprefix.test/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
}
TEST(TestCookie, BlockUnicode)
{
Preferences::SetBool("network.cookie.blockUnicode", true);
nsresult rv;
nsCString cookie;
nsCOMPtr<nsICookieService> cookieService =
do_GetService(kCookieServiceCID, &rv);
ASSERT_NS_SUCCEEDED(rv);
SetACookie(cookieService, "http://unicode.com/", "name=🍪");
GetACookie(cookieService, "http://unicode.com/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
SetACookie(cookieService, "http://unicode.com/", "🍪=value");
GetACookie(cookieService, "http://unicode.com/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL));
Preferences::SetBool("network.cookie.blockUnicode", false);
SetACookie(cookieService, "http://unicode.com/", "name=🍪");
GetACookie(cookieService, "http://unicode.com/", cookie);
EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "name=🍪"));
nsCOMPtr<nsICookieManager> cookieMgr =
do_GetService(NS_COOKIEMANAGER_CONTRACTID);
EXPECT_NS_SUCCEEDED(cookieMgr->RemoveAll());
SetACookie(cookieService, "http://unicode.com/", "🍪=value");
GetACookie(cookieService, "http://unicode.com/", cookie);
printf("cookie:%s\n", cookie.get());
EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "🍪=value"));
EXPECT_NS_SUCCEEDED(cookieMgr->RemoveAll());
Preferences::ClearUser("network.cookie.blockUnicode");
}

View File

@ -12548,17 +12548,6 @@
],
"description": "Percentage of the entries with the given content type. Numbers are sampled periodically, every time 2GB of data is written to the cache."
},
"NETWORK_COOKIE_UNICODE_BYTE" :{
"record_in_processes": ["main"],
"products": ["firefox"],
"alert_emails": ["necko@mozilla.com", "vgosu@mozilla.com"],
"bug_numbers": [1797231],
"expires_in_version": "120",
"kind": "categorical",
"releaseChannelCollection": "opt-out",
"description": "Records whether a cookie contains unexpected characters",
"labels": ["none", "unicodeName", "unicodeValue"]
},
"SSL_TLS13_INTOLERANCE_REASON_PRE": {
"record_in_processes": ["main", "content"],
"products": ["firefox", "fennec"],