| Index: Source/core/dom/SandboxFlags.cpp
|
| diff --git a/Source/core/dom/SandboxFlags.cpp b/Source/core/dom/SandboxFlags.cpp
|
| index 8d8e01c2f7971c60a5cb31dd3e1df6f1aa0d0f6c..c6b531c627fc60efde69e3a94782ca91aaabc9de 100644
|
| --- a/Source/core/dom/SandboxFlags.cpp
|
| +++ b/Source/core/dom/SandboxFlags.cpp
|
| @@ -91,4 +91,43 @@ SandboxFlags parseSandboxPolicy(const String& policy, String& invalidTokensError
|
| return flags;
|
| }
|
|
|
| +String parseSuboriginName(const String& policy, String& invalidTokensErrorMessage)
|
| +{
|
| + // Parse the name of the suborigin (no spaces, single string)
|
| + unsigned length = policy.length();
|
| + unsigned start = 0;
|
| + while (start < length && isHTMLSpace<UChar>(policy[start]))
|
| + ++start;
|
| +
|
| + if (start >= length) {
|
| + invalidTokensErrorMessage = "No suborigin name specified.";
|
| + return "";
|
| + }
|
| +
|
| + unsigned end = start + 1;
|
| + while (end < length && !isHTMLSpace<UChar>(policy[end])) {
|
| + if (!isASCIIAlphanumeric<UChar>(policy[end])) {
|
| + invalidTokensErrorMessage = "Invalid character \'" + policy.substring(end, 1) + "\' in suborigin.";
|
| + }
|
| + ++end;
|
| + }
|
| +
|
| + if (start >= end) {
|
| + invalidTokensErrorMessage = "Empty suborigin name specified.";
|
| + return "";
|
| + }
|
| +
|
| + unsigned finalSpaces = end + 1;
|
| + // Make sure there is nothing else specified after the final space.
|
| + while (finalSpaces < length && isHTMLSpace<UChar>(policy[finalSpaces]))
|
| + ++finalSpaces;
|
| +
|
| + if (finalSpaces < length) {
|
| + invalidTokensErrorMessage = "There cannot be any spaces in the suborigin name.";
|
| + return "";
|
| + }
|
| +
|
| + return policy.substring(start, end - start);
|
| +}
|
| +
|
| }
|
|
|