Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All Rights Reserved. | 2 * Copyright (C) 2013 Google Inc. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 * | 24 * |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #include "config.h" | 27 #include "config.h" |
| 28 #include "core/dom/SandboxFlags.h" | 28 #include "core/dom/SandboxFlags.h" |
| 29 | 29 |
| 30 #include "core/html/parser/HTMLParserIdioms.h" | 30 #include "core/html/parser/HTMLParserIdioms.h" |
| 31 #include "platform/RuntimeEnabledFeatures.h" | |
| 31 #include "wtf/text/StringBuilder.h" | 32 #include "wtf/text/StringBuilder.h" |
| 32 | 33 |
| 33 namespace blink { | 34 namespace blink { |
| 34 | 35 |
| 35 SandboxFlags parseSandboxPolicy(const String& policy, String& invalidTokensError Message) | 36 SandboxFlags parseSandboxPolicy(const String& policy, String& invalidTokensError Message) |
| 36 { | 37 { |
| 37 SpaceSplitString policyTokens(AtomicString(policy), SpaceSplitString::Should NotFoldCase); | 38 SpaceSplitString policyTokens(AtomicString(policy), SpaceSplitString::Should NotFoldCase); |
| 38 return parseSandboxPolicy(policyTokens, invalidTokensErrorMessage); | 39 return parseSandboxPolicy(policyTokens, invalidTokensErrorMessage); |
| 39 } | 40 } |
| 40 | 41 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 58 flags &= ~SandboxScripts; | 59 flags &= ~SandboxScripts; |
| 59 flags &= ~SandboxAutomaticFeatures; | 60 flags &= ~SandboxAutomaticFeatures; |
| 60 } else if (equalIgnoringCase(sandboxToken, "allow-top-navigation")) { | 61 } else if (equalIgnoringCase(sandboxToken, "allow-top-navigation")) { |
| 61 flags &= ~SandboxTopNavigation; | 62 flags &= ~SandboxTopNavigation; |
| 62 } else if (equalIgnoringCase(sandboxToken, "allow-popups")) { | 63 } else if (equalIgnoringCase(sandboxToken, "allow-popups")) { |
| 63 flags &= ~SandboxPopups; | 64 flags &= ~SandboxPopups; |
| 64 } else if (equalIgnoringCase(sandboxToken, "allow-pointer-lock")) { | 65 } else if (equalIgnoringCase(sandboxToken, "allow-pointer-lock")) { |
| 65 flags &= ~SandboxPointerLock; | 66 flags &= ~SandboxPointerLock; |
| 66 } else if (equalIgnoringCase(sandboxToken, "allow-orientation-lock")) { | 67 } else if (equalIgnoringCase(sandboxToken, "allow-orientation-lock")) { |
| 67 flags &= ~SandboxOrientationLock; | 68 flags &= ~SandboxOrientationLock; |
| 69 } else if (equalIgnoringCase(sandboxToken, "allow-unsandboxed-auxiliary" )) { | |
| 70 if (RuntimeEnabledFeatures::unsandboxedAuxiliaryEnabled()) | |
|
philipj_slow
2015/05/13 10:36:19
Should this check not be moved into the containing
Mike West
2015/05/13 11:22:01
It should!
| |
| 71 flags &= ~SandboxUnsandboxedAuxiliary; | |
| 68 } else { | 72 } else { |
| 69 if (numberOfTokenErrors) | 73 if (numberOfTokenErrors) |
| 70 tokenErrors.appendLiteral(", '"); | 74 tokenErrors.appendLiteral(", '"); |
| 71 else | 75 else |
| 72 tokenErrors.append('\''); | 76 tokenErrors.append('\''); |
| 73 tokenErrors.append(sandboxToken); | 77 tokenErrors.append(sandboxToken); |
| 74 tokenErrors.append('\''); | 78 tokenErrors.append('\''); |
| 75 numberOfTokenErrors++; | 79 numberOfTokenErrors++; |
| 76 } | 80 } |
| 77 } | 81 } |
| 78 | 82 |
| 79 if (numberOfTokenErrors) { | 83 if (numberOfTokenErrors) { |
| 80 if (numberOfTokenErrors > 1) | 84 if (numberOfTokenErrors > 1) |
| 81 tokenErrors.appendLiteral(" are invalid sandbox flags."); | 85 tokenErrors.appendLiteral(" are invalid sandbox flags."); |
| 82 else | 86 else |
| 83 tokenErrors.appendLiteral(" is an invalid sandbox flag."); | 87 tokenErrors.appendLiteral(" is an invalid sandbox flag."); |
| 84 invalidTokensErrorMessage = tokenErrors.toString(); | 88 invalidTokensErrorMessage = tokenErrors.toString(); |
| 85 } | 89 } |
| 86 | 90 |
| 87 return flags; | 91 return flags; |
| 88 } | 92 } |
| 89 | 93 |
| 90 } | 94 } |
| OLD | NEW |