| 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" |
| 30 #include "wtf/text/StringBuilder.h" | 31 #include "wtf/text/StringBuilder.h" |
| 31 | 32 |
| 32 namespace blink { | 33 namespace blink { |
| 33 | 34 |
| 34 SandboxFlags parseSandboxPolicy(const SpaceSplitString& policy, | 35 SandboxFlags parseSandboxPolicy(const SpaceSplitString& policy, |
| 35 String& invalidTokensErrorMessage) { | 36 String& invalidTokensErrorMessage) { |
| 36 // http://www.w3.org/TR/html5/the-iframe-element.html#attr-iframe-sandbox | 37 // http://www.w3.org/TR/html5/the-iframe-element.html#attr-iframe-sandbox |
| 37 // Parse the unordered set of unique space-separated tokens. | 38 // Parse the unordered set of unique space-separated tokens. |
| 38 SandboxFlags flags = SandboxAll; | 39 SandboxFlags flags = SandboxAll; |
| 39 unsigned length = policy.size(); | 40 unsigned length = policy.size(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 58 flags &= ~SandboxPointerLock; | 59 flags &= ~SandboxPointerLock; |
| 59 } else if (equalIgnoringCase(sandboxToken, "allow-orientation-lock")) { | 60 } else if (equalIgnoringCase(sandboxToken, "allow-orientation-lock")) { |
| 60 flags &= ~SandboxOrientationLock; | 61 flags &= ~SandboxOrientationLock; |
| 61 } else if (equalIgnoringCase(sandboxToken, | 62 } else if (equalIgnoringCase(sandboxToken, |
| 62 "allow-popups-to-escape-sandbox")) { | 63 "allow-popups-to-escape-sandbox")) { |
| 63 flags &= ~SandboxPropagatesToAuxiliaryBrowsingContexts; | 64 flags &= ~SandboxPropagatesToAuxiliaryBrowsingContexts; |
| 64 } else if (equalIgnoringCase(sandboxToken, "allow-modals")) { | 65 } else if (equalIgnoringCase(sandboxToken, "allow-modals")) { |
| 65 flags &= ~SandboxModals; | 66 flags &= ~SandboxModals; |
| 66 } else if (equalIgnoringCase(sandboxToken, "allow-presentation")) { | 67 } else if (equalIgnoringCase(sandboxToken, "allow-presentation")) { |
| 67 flags &= ~SandboxPresentation; | 68 flags &= ~SandboxPresentation; |
| 69 } else if (equalIgnoringCase(sandboxToken, |
| 70 "allow-top-navigation-with-user-activation") && |
| 71 RuntimeEnabledFeatures:: |
| 72 topNavWithUserActivationInSandboxEnabled()) { |
| 73 flags &= ~SandboxTopNavigationWithUserActivation; |
| 68 } else { | 74 } else { |
| 69 if (numberOfTokenErrors) | 75 if (numberOfTokenErrors) |
| 70 tokenErrors.append(", '"); | 76 tokenErrors.append(", '"); |
| 71 else | 77 else |
| 72 tokenErrors.append('\''); | 78 tokenErrors.append('\''); |
| 73 tokenErrors.append(sandboxToken); | 79 tokenErrors.append(sandboxToken); |
| 74 tokenErrors.append('\''); | 80 tokenErrors.append('\''); |
| 75 numberOfTokenErrors++; | 81 numberOfTokenErrors++; |
| 76 } | 82 } |
| 77 } | 83 } |
| 78 | 84 |
| 79 if (numberOfTokenErrors) { | 85 if (numberOfTokenErrors) { |
| 80 if (numberOfTokenErrors > 1) | 86 if (numberOfTokenErrors > 1) |
| 81 tokenErrors.append(" are invalid sandbox flags."); | 87 tokenErrors.append(" are invalid sandbox flags."); |
| 82 else | 88 else |
| 83 tokenErrors.append(" is an invalid sandbox flag."); | 89 tokenErrors.append(" is an invalid sandbox flag."); |
| 84 invalidTokensErrorMessage = tokenErrors.toString(); | 90 invalidTokensErrorMessage = tokenErrors.toString(); |
| 85 } | 91 } |
| 86 | 92 |
| 87 return flags; | 93 return flags; |
| 88 } | 94 } |
| 89 | 95 |
| 90 } // namespace blink | 96 } // namespace blink |
| OLD | NEW |