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"
) && RuntimeEnabledFeatures::unsandboxedAuxiliaryEnabled()) { |
| 70 flags &= ~SandboxPropagatesToAuxiliaryBrowsingContexts; |
68 } else { | 71 } else { |
69 if (numberOfTokenErrors) | 72 if (numberOfTokenErrors) |
70 tokenErrors.appendLiteral(", '"); | 73 tokenErrors.appendLiteral(", '"); |
71 else | 74 else |
72 tokenErrors.append('\''); | 75 tokenErrors.append('\''); |
73 tokenErrors.append(sandboxToken); | 76 tokenErrors.append(sandboxToken); |
74 tokenErrors.append('\''); | 77 tokenErrors.append('\''); |
75 numberOfTokenErrors++; | 78 numberOfTokenErrors++; |
76 } | 79 } |
77 } | 80 } |
78 | 81 |
79 if (numberOfTokenErrors) { | 82 if (numberOfTokenErrors) { |
80 if (numberOfTokenErrors > 1) | 83 if (numberOfTokenErrors > 1) |
81 tokenErrors.appendLiteral(" are invalid sandbox flags."); | 84 tokenErrors.appendLiteral(" are invalid sandbox flags."); |
82 else | 85 else |
83 tokenErrors.appendLiteral(" is an invalid sandbox flag."); | 86 tokenErrors.appendLiteral(" is an invalid sandbox flag."); |
84 invalidTokensErrorMessage = tokenErrors.toString(); | 87 invalidTokensErrorMessage = tokenErrors.toString(); |
85 } | 88 } |
86 | 89 |
87 return flags; | 90 return flags; |
88 } | 91 } |
89 | 92 |
90 } | 93 } |
OLD | NEW |