| 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/HTMLIFrameElement.h" |
| 29 #include "core/html/parser/HTMLParserIdioms.h" | 30 #include "core/html/parser/HTMLParserIdioms.h" |
| 30 #include "platform/RuntimeEnabledFeatures.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 SpaceSplitString& policy, | 36 SandboxFlags parseSandboxPolicy(const SpaceSplitString& policy, |
| 36 String& invalidTokensErrorMessage) { | 37 String& invalidTokensErrorMessage) { |
| 37 // http://www.w3.org/TR/html5/the-iframe-element.html#attr-iframe-sandbox | 38 // http://www.w3.org/TR/html5/the-iframe-element.html#attr-iframe-sandbox |
| 38 // Parse the unordered set of unique space-separated tokens. | 39 // Parse the unordered set of unique space-separated tokens. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 65 } else if (equalIgnoringCase(sandboxToken, "allow-modals")) { | 66 } else if (equalIgnoringCase(sandboxToken, "allow-modals")) { |
| 66 flags &= ~SandboxModals; | 67 flags &= ~SandboxModals; |
| 67 } else if (equalIgnoringCase(sandboxToken, "allow-presentation")) { | 68 } else if (equalIgnoringCase(sandboxToken, "allow-presentation")) { |
| 68 flags &= ~SandboxPresentation; | 69 flags &= ~SandboxPresentation; |
| 69 } else if (equalIgnoringCase(sandboxToken, | 70 } else if (equalIgnoringCase(sandboxToken, |
| 70 "allow-top-navigation-with-user-activation") && | 71 "allow-top-navigation-with-user-activation") && |
| 71 RuntimeEnabledFeatures:: | 72 RuntimeEnabledFeatures:: |
| 72 topNavWithUserActivationInSandboxEnabled()) { | 73 topNavWithUserActivationInSandboxEnabled()) { |
| 73 flags &= ~SandboxTopNavigationWithUserActivation; | 74 flags &= ~SandboxTopNavigationWithUserActivation; |
| 74 } else { | 75 } else { |
| 75 if (numberOfTokenErrors) | 76 tokenErrors.append(tokenErrors.isEmpty() ? "'" : ", '"); |
| 76 tokenErrors.append(", '"); | |
| 77 else | |
| 78 tokenErrors.append('\''); | |
| 79 tokenErrors.append(sandboxToken); | 77 tokenErrors.append(sandboxToken); |
| 80 tokenErrors.append('\''); | 78 tokenErrors.append("'"); |
| 81 numberOfTokenErrors++; | 79 numberOfTokenErrors++; |
| 82 } | 80 } |
| 83 } | 81 } |
| 84 | 82 |
| 85 if (numberOfTokenErrors) { | 83 if (numberOfTokenErrors) { |
| 86 if (numberOfTokenErrors > 1) | 84 tokenErrors.append(numberOfTokenErrors > 1 |
| 87 tokenErrors.append(" are invalid sandbox flags."); | 85 ? " are invalid sandbox flags." |
| 88 else | 86 : " is an invalid sandbox flag."); |
| 89 tokenErrors.append(" is an invalid sandbox flag."); | |
| 90 invalidTokensErrorMessage = tokenErrors.toString(); | 87 invalidTokensErrorMessage = tokenErrors.toString(); |
| 91 } | 88 } |
| 92 | 89 |
| 93 return flags; | 90 return flags; |
| 94 } | 91 } |
| 95 | 92 |
| 96 } // namespace blink | 93 } // namespace blink |
| OLD | NEW |