Commit e6e49f4b authored by Jochen Eisinger's avatar Jochen Eisinger Committed by Commit Bot

Add back support for "none" referrer policy

It's a legacy keyword that was accidentially removed

BUG=615608
R=estark@chromium.org

Change-Id: I1bf4d87d999f35b30beca644b4dec6712ac2d388
Reviewed-on: https://chromium-review.googlesource.com/772234Reviewed-by: default avatarMike West <mkwst@chromium.org>
Commit-Queue: Jochen Eisinger <jochen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#517114}
parent b28710ea
......@@ -284,7 +284,8 @@ bool SecurityPolicy::ReferrerPolicyFromString(
(legacy_keywords_support == kSupportReferrerPolicyLegacyKeywords);
if (EqualIgnoringASCIICase(policy, "no-referrer") ||
(support_legacy_keywords && EqualIgnoringASCIICase(policy, "never"))) {
(support_legacy_keywords && (EqualIgnoringASCIICase(policy, "never") ||
EqualIgnoringASCIICase(policy, "none")))) {
*result = kReferrerPolicyNever;
return true;
}
......
......@@ -213,23 +213,31 @@ TEST(SecurityPolicyTest, ReferrerPolicyFromHeaderValue) {
struct TestCase {
const char* header;
bool is_valid;
ReferrerPolicyLegacyKeywordsSupport keywords;
ReferrerPolicy expected_policy;
};
TestCase inputs[] = {
{"origin", true, kReferrerPolicyOrigin},
{"foo", false, kReferrerPolicyDefault},
{"origin, foo", true, kReferrerPolicyOrigin},
{"origin, foo-bar", true, kReferrerPolicyOrigin},
{"origin, foo bar", false, kReferrerPolicyDefault},
{"origin", true, kDoNotSupportReferrerPolicyLegacyKeywords,
kReferrerPolicyOrigin},
{"none", true, kSupportReferrerPolicyLegacyKeywords,
kReferrerPolicyNever},
{"none", false, kDoNotSupportReferrerPolicyLegacyKeywords,
kReferrerPolicyDefault},
{"foo", false, kDoNotSupportReferrerPolicyLegacyKeywords,
kReferrerPolicyDefault},
{"origin, foo", true, kDoNotSupportReferrerPolicyLegacyKeywords,
kReferrerPolicyOrigin},
{"origin, foo-bar", true, kDoNotSupportReferrerPolicyLegacyKeywords,
kReferrerPolicyOrigin},
{"origin, foo bar", false, kDoNotSupportReferrerPolicyLegacyKeywords,
kReferrerPolicyDefault},
};
for (TestCase test : inputs) {
ReferrerPolicy actual_policy = kReferrerPolicyDefault;
EXPECT_EQ(test.is_valid,
SecurityPolicy::ReferrerPolicyFromHeaderValue(
test.header, kDoNotSupportReferrerPolicyLegacyKeywords,
&actual_policy));
EXPECT_EQ(test.is_valid, SecurityPolicy::ReferrerPolicyFromHeaderValue(
test.header, test.keywords, &actual_policy));
if (test.is_valid)
EXPECT_EQ(test.expected_policy, actual_policy);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment