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 |
11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
12 * | 12 * |
13 * THIS SOFTWARE IS PROVIDED BY GOOGLE, INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY GOOGLE, INC. ``AS IS'' AND ANY |
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
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 "core/dom/SandboxFlags.h" | 27 #include "core/dom/SandboxFlags.h" |
28 | 28 |
29 #include "core/html/parser/HTMLParserIdioms.h" | 29 #include "core/html/parser/HTMLParserIdioms.h" |
30 #include "platform/RuntimeEnabledFeatures.h" | |
31 #include "wtf/text/StringBuilder.h" | 30 #include "wtf/text/StringBuilder.h" |
32 | 31 |
33 namespace blink { | 32 namespace blink { |
34 | 33 |
35 SandboxFlags parseSandboxPolicy(const SpaceSplitString& policy, | 34 SandboxFlags parseSandboxPolicy(const SpaceSplitString& policy, |
36 String& invalidTokensErrorMessage) { | 35 String& invalidTokensErrorMessage) { |
37 // http://www.w3.org/TR/html5/the-iframe-element.html#attr-iframe-sandbox | 36 // http://www.w3.org/TR/html5/the-iframe-element.html#attr-iframe-sandbox |
38 // Parse the unordered set of unique space-separated tokens. | 37 // Parse the unordered set of unique space-separated tokens. |
39 SandboxFlags flags = SandboxAll; | 38 SandboxFlags flags = SandboxAll; |
40 unsigned length = policy.size(); | 39 unsigned length = policy.size(); |
(...skipping 12 matching lines...) Expand all Loading... |
53 flags &= ~SandboxAutomaticFeatures; | 52 flags &= ~SandboxAutomaticFeatures; |
54 } else if (equalIgnoringCase(sandboxToken, "allow-top-navigation")) { | 53 } else if (equalIgnoringCase(sandboxToken, "allow-top-navigation")) { |
55 flags &= ~SandboxTopNavigation; | 54 flags &= ~SandboxTopNavigation; |
56 } else if (equalIgnoringCase(sandboxToken, "allow-popups")) { | 55 } else if (equalIgnoringCase(sandboxToken, "allow-popups")) { |
57 flags &= ~SandboxPopups; | 56 flags &= ~SandboxPopups; |
58 } else if (equalIgnoringCase(sandboxToken, "allow-pointer-lock")) { | 57 } else if (equalIgnoringCase(sandboxToken, "allow-pointer-lock")) { |
59 flags &= ~SandboxPointerLock; | 58 flags &= ~SandboxPointerLock; |
60 } else if (equalIgnoringCase(sandboxToken, "allow-orientation-lock")) { | 59 } else if (equalIgnoringCase(sandboxToken, "allow-orientation-lock")) { |
61 flags &= ~SandboxOrientationLock; | 60 flags &= ~SandboxOrientationLock; |
62 } else if (equalIgnoringCase(sandboxToken, | 61 } else if (equalIgnoringCase(sandboxToken, |
63 "allow-popups-to-escape-sandbox") && | 62 "allow-popups-to-escape-sandbox")) { |
64 RuntimeEnabledFeatures::unsandboxedAuxiliaryEnabled()) { | |
65 flags &= ~SandboxPropagatesToAuxiliaryBrowsingContexts; | 63 flags &= ~SandboxPropagatesToAuxiliaryBrowsingContexts; |
66 } else if (equalIgnoringCase(sandboxToken, "allow-modals")) { | 64 } else if (equalIgnoringCase(sandboxToken, "allow-modals")) { |
67 flags &= ~SandboxModals; | 65 flags &= ~SandboxModals; |
68 } else if (equalIgnoringCase(sandboxToken, "allow-presentation")) { | 66 } else if (equalIgnoringCase(sandboxToken, "allow-presentation")) { |
69 flags &= ~SandboxPresentation; | 67 flags &= ~SandboxPresentation; |
70 } else { | 68 } else { |
71 if (numberOfTokenErrors) | 69 if (numberOfTokenErrors) |
72 tokenErrors.append(", '"); | 70 tokenErrors.append(", '"); |
73 else | 71 else |
74 tokenErrors.append('\''); | 72 tokenErrors.append('\''); |
75 tokenErrors.append(sandboxToken); | 73 tokenErrors.append(sandboxToken); |
76 tokenErrors.append('\''); | 74 tokenErrors.append('\''); |
77 numberOfTokenErrors++; | 75 numberOfTokenErrors++; |
78 } | 76 } |
79 } | 77 } |
80 | 78 |
81 if (numberOfTokenErrors) { | 79 if (numberOfTokenErrors) { |
82 if (numberOfTokenErrors > 1) | 80 if (numberOfTokenErrors > 1) |
83 tokenErrors.append(" are invalid sandbox flags."); | 81 tokenErrors.append(" are invalid sandbox flags."); |
84 else | 82 else |
85 tokenErrors.append(" is an invalid sandbox flag."); | 83 tokenErrors.append(" is an invalid sandbox flag."); |
86 invalidTokensErrorMessage = tokenErrors.toString(); | 84 invalidTokensErrorMessage = tokenErrors.toString(); |
87 } | 85 } |
88 | 86 |
89 return flags; | 87 return flags; |
90 } | 88 } |
91 | 89 |
92 } // namespace blink | 90 } // namespace blink |
OLD | NEW |