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( ...@@ -284,7 +284,8 @@ bool SecurityPolicy::ReferrerPolicyFromString(
(legacy_keywords_support == kSupportReferrerPolicyLegacyKeywords); (legacy_keywords_support == kSupportReferrerPolicyLegacyKeywords);
if (EqualIgnoringASCIICase(policy, "no-referrer") || if (EqualIgnoringASCIICase(policy, "no-referrer") ||
(support_legacy_keywords && EqualIgnoringASCIICase(policy, "never"))) { (support_legacy_keywords && (EqualIgnoringASCIICase(policy, "never") ||
EqualIgnoringASCIICase(policy, "none")))) {
*result = kReferrerPolicyNever; *result = kReferrerPolicyNever;
return true; return true;
} }
......
...@@ -213,23 +213,31 @@ TEST(SecurityPolicyTest, ReferrerPolicyFromHeaderValue) { ...@@ -213,23 +213,31 @@ TEST(SecurityPolicyTest, ReferrerPolicyFromHeaderValue) {
struct TestCase { struct TestCase {
const char* header; const char* header;
bool is_valid; bool is_valid;
ReferrerPolicyLegacyKeywordsSupport keywords;
ReferrerPolicy expected_policy; ReferrerPolicy expected_policy;
}; };
TestCase inputs[] = { TestCase inputs[] = {
{"origin", true, kReferrerPolicyOrigin}, {"origin", true, kDoNotSupportReferrerPolicyLegacyKeywords,
{"foo", false, kReferrerPolicyDefault}, kReferrerPolicyOrigin},
{"origin, foo", true, kReferrerPolicyOrigin}, {"none", true, kSupportReferrerPolicyLegacyKeywords,
{"origin, foo-bar", true, kReferrerPolicyOrigin}, kReferrerPolicyNever},
{"origin, foo bar", false, kReferrerPolicyDefault}, {"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) { for (TestCase test : inputs) {
ReferrerPolicy actual_policy = kReferrerPolicyDefault; ReferrerPolicy actual_policy = kReferrerPolicyDefault;
EXPECT_EQ(test.is_valid, EXPECT_EQ(test.is_valid, SecurityPolicy::ReferrerPolicyFromHeaderValue(
SecurityPolicy::ReferrerPolicyFromHeaderValue( test.header, test.keywords, &actual_policy));
test.header, kDoNotSupportReferrerPolicyLegacyKeywords,
&actual_policy));
if (test.is_valid) if (test.is_valid)
EXPECT_EQ(test.expected_policy, actual_policy); 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