Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Fix hyphen disallowed in Suborigin names
Browse files Browse the repository at this point in the history
According to the proposed spec, Suborigin names should allow
alphanumeric characters and hyphens. This fixes a bug where hyphens were
disallowed, and it adds tests to verify the behavior.

BUG=568755
[email protected]

Review URL: https://codereview.chromium.org/1620393002

Cr-Commit-Position: refs/heads/master@{#371381}
  • Loading branch information
joelweinberger authored and Commit bot committed Jan 26, 2016
1 parent e1758d3 commit 45a6c69
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ ALERT: SecurityError: Blocked a frame with origin "http://127.0.0.1:8000" from a
ALERT: SecurityError: Blocked a frame with origin "http://127.0.0.1:8000" from accessing a cross-origin frame.
ALERT: SecurityError: Blocked a frame with origin "http://127.0.0.1:8000" from accessing a cross-origin frame.
ALERT: SecurityError: Blocked a frame with origin "http://127.0.0.1:8000" from accessing a cross-origin frame.
ALERT: SecurityError: Blocked a frame with origin "http://127.0.0.1:8000" from accessing a cross-origin frame.
ALERT: SecurityError: Blocked a frame with origin "http://127.0.0.1:8000" from accessing a cross-origin frame.
ALERT: SecurityError: Blocked a frame with origin "http://127.0.0.1:8000" from accessing a cross-origin frame.

Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
"Foobar",
"FOOBAR",
"42",
"foo-bar",
"-foobar",
"foobar-"
];

var iframe;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ String getSha256String(const String& content)
return "sha256-" + base64Encode(reinterpret_cast<char*>(digest.data()), digest.size(), Base64DoNotInsertLFs);
}

template<typename CharType> inline bool isASCIIAlphanumericOrHyphen(CharType c)
{
return isASCIIAlphanumeric(c) || c == '-';
}

} // namespace

CSPDirectiveList::CSPDirectiveList(ContentSecurityPolicy* policy, ContentSecurityPolicyHeaderType type, ContentSecurityPolicyHeaderSource source)
Expand Down Expand Up @@ -719,7 +724,7 @@ String CSPDirectiveList::parseSuboriginName(const String& policy)

const UChar* begin = position;

skipWhile<UChar, isASCIIAlphanumeric>(position, end);
skipWhile<UChar, isASCIIAlphanumericOrHyphen>(position, end);
if (position != end && !isASCIISpace(*position)) {
m_policy->reportInvalidSuboriginFlags("Invalid character \'" + String(position, 1) + "\' in suborigin.");
return String();
Expand Down

0 comments on commit 45a6c69

Please sign in to comment.