From 901620ce26952ba2398fe022e5bb7be7f062b535 Mon Sep 17 00:00:00 2001 From: jww Date: Thu, 9 Jun 2016 18:00:10 -0700 Subject: [PATCH] Update Suborigins grammar to match spec changes The spec took away semicolons from the grammar because they were unnecessary. This CL updates the implementation and tests accordingly. BUG=336894 TBR=mkwst@chromium.org Review-Url: https://codereview.chromium.org/2052033002 Cr-Commit-Position: refs/heads/master@{#399061} --- .../suborigin-unsafe-postmessage-receive.php | 2 +- .../suborigin-unsafe-postmessage-send.html | 4 +-- .../Source/platform/network/HTTPParsers.cpp | 10 ------- .../platform/network/HTTPParsersTest.cpp | 26 +++++++++---------- 4 files changed, 16 insertions(+), 26 deletions(-) diff --git a/third_party/WebKit/LayoutTests/http/tests/security/suborigins/suborigin-unsafe-postmessage-receive.php b/third_party/WebKit/LayoutTests/http/tests/security/suborigins/suborigin-unsafe-postmessage-receive.php index be0ab91bf4b6c..2c36e49761af2 100644 --- a/third_party/WebKit/LayoutTests/http/tests/security/suborigins/suborigin-unsafe-postmessage-receive.php +++ b/third_party/WebKit/LayoutTests/http/tests/security/suborigins/suborigin-unsafe-postmessage-receive.php @@ -1,5 +1,5 @@ diff --git a/third_party/WebKit/LayoutTests/http/tests/security/suborigins/suborigin-unsafe-postmessage-send.html b/third_party/WebKit/LayoutTests/http/tests/security/suborigins/suborigin-unsafe-postmessage-send.html index a913d8faffc53..3dae87e2e036c 100644 --- a/third_party/WebKit/LayoutTests/http/tests/security/suborigins/suborigin-unsafe-postmessage-send.html +++ b/third_party/WebKit/LayoutTests/http/tests/security/suborigins/suborigin-unsafe-postmessage-send.html @@ -30,7 +30,7 @@ } -window.open("resources/post-document-to-parent.php?suborigin=foobar2&type=window&suboriginpolicy='unsafe-postmessage-send';"); +window.open("resources/post-document-to-parent.php?suborigin=foobar2&type=window&suboriginpolicy='unsafe-postmessage-send'"); - + diff --git a/third_party/WebKit/Source/platform/network/HTTPParsers.cpp b/third_party/WebKit/Source/platform/network/HTTPParsers.cpp index 64cf6fd34458c..ab68c140e81c5 100644 --- a/third_party/WebKit/Source/platform/network/HTTPParsers.cpp +++ b/third_party/WebKit/Source/platform/network/HTTPParsers.cpp @@ -740,16 +740,6 @@ bool parseSuboriginHeader(const String& header, Suborigin* suborigin, WTF::Vecto messages.append("Ignoring unknown suborigin policy option " + optionName + "."); else suborigin->addPolicyOption(option); - - skipWhile(position, end); - if (position == end || *position != ';') { - String found = (position == end) ? "end of string" : String(position, 1); - messages.append("Invalid suborigin policy Expected ';' at end of policy option. Found \'" + found + "\' instead."); - suborigin->clear(); - return false; - } - - position++; } return true; diff --git a/third_party/WebKit/Source/platform/network/HTTPParsersTest.cpp b/third_party/WebKit/Source/platform/network/HTTPParsersTest.cpp index 1937d65b8ae6e..fa970a346f102 100644 --- a/third_party/WebKit/Source/platform/network/HTTPParsersTest.cpp +++ b/third_party/WebKit/Source/platform/network/HTTPParsersTest.cpp @@ -256,25 +256,25 @@ TEST(HTTPParsersTest, SuboriginParseValidPolicy) const Suborigin::SuboriginPolicyOptions unsafePostmessageSendAndReceive[] = { Suborigin::SuboriginPolicyOptions::UnsafePostMessageSend, Suborigin::SuboriginPolicyOptions::UnsafePostMessageReceive }; // All simple, valid policies - expectParsePolicyPass("One policy, unsafe-postmessage-send", "foobar 'unsafe-postmessage-send';", unsafePostmessageSend, ARRAY_SIZE(unsafePostmessageSend)); - expectParsePolicyPass("One policy, unsafe-postmessage-receive", "foobar 'unsafe-postmessage-receive';", unsafePostmessageReceive, ARRAY_SIZE(unsafePostmessageReceive)); + expectParsePolicyPass("One policy, unsafe-postmessage-send", "foobar 'unsafe-postmessage-send'", unsafePostmessageSend, ARRAY_SIZE(unsafePostmessageSend)); + expectParsePolicyPass("One policy, unsafe-postmessage-receive", "foobar 'unsafe-postmessage-receive'", unsafePostmessageReceive, ARRAY_SIZE(unsafePostmessageReceive)); // Formatting differences of policies and multiple policies - expectParsePolicyPass("One policy, whitespace all around", "foobar 'unsafe-postmessage-send' ; ", unsafePostmessageSend, ARRAY_SIZE(unsafePostmessageSend)); - expectParsePolicyPass("Multiple, same policies", "foobar 'unsafe-postmessage-send'; 'unsafe-postmessage-send';", unsafePostmessageSend, ARRAY_SIZE(unsafePostmessageSend)); - expectParsePolicyPass("Multiple, different policies", "foobar 'unsafe-postmessage-send'; 'unsafe-postmessage-receive';", unsafePostmessageSendAndReceive, ARRAY_SIZE(unsafePostmessageSendAndReceive)); - expectParsePolicyPass("One policy, unknown option", "foobar 'unknown-option';", {}, 0); + expectParsePolicyPass("One policy, whitespace all around", "foobar 'unsafe-postmessage-send' ", unsafePostmessageSend, ARRAY_SIZE(unsafePostmessageSend)); + expectParsePolicyPass("Multiple, same policies", "foobar 'unsafe-postmessage-send' 'unsafe-postmessage-send'", unsafePostmessageSend, ARRAY_SIZE(unsafePostmessageSend)); + expectParsePolicyPass("Multiple, different policies", "foobar 'unsafe-postmessage-send' 'unsafe-postmessage-receive'", unsafePostmessageSendAndReceive, ARRAY_SIZE(unsafePostmessageSendAndReceive)); + expectParsePolicyPass("One policy, unknown option", "foobar 'unknown-option'", {}, 0); } TEST(HTTPParsersTest, SuboriginParseInvalidPolicy) { - expectParsePolicyFail("One policy, no suborigin name", "'unsafe-postmessage-send';"); - expectParsePolicyFail("One policy, invalid characters", "foobar 'un$afe-postmessage-send';"); - expectParsePolicyFail("One policy, caps", "foobar 'UNSAFE-POSTMESSAGE-SEND';"); - expectParsePolicyFail("One policy, missing first quote", "foobar unsafe-postmessage-send';"); - expectParsePolicyFail("One policy, missing last quote", "foobar 'unsafe-postmessage-send;"); - expectParsePolicyFail("One policy, missing semicolon at end", "foobar 'unsafe-postmessage-send'"); - expectParsePolicyFail("Multiple policies, missing semicolon between options", "foobar 'unsafe-postmessage-send' 'unsafe-postmessage-send';"); + expectParsePolicyFail("One policy, no suborigin name", "'unsafe-postmessage-send'"); + expectParsePolicyFail("One policy, invalid characters", "foobar 'un$afe-postmessage-send'"); + expectParsePolicyFail("One policy, caps", "foobar 'UNSAFE-POSTMESSAGE-SEND'"); + expectParsePolicyFail("One policy, missing first quote", "foobar unsafe-postmessage-send'"); + expectParsePolicyFail("One policy, missing last quote", "foobar 'unsafe-postmessage-send"); + expectParsePolicyFail("One policy, invalid character at end", "foobar 'unsafe-postmessage-send';"); + expectParsePolicyFail("Multiple policies, extra character between options", "foobar 'unsafe-postmessage-send' ; 'unsafe-postmessage-send'"); } } // namespace blink