| 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 27 matching lines...) Expand all Loading... |
| 38 // 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 |
| 39 // Parse the unordered set of unique space-separated tokens. | 39 // Parse the unordered set of unique space-separated tokens. |
| 40 SandboxFlags flags = kSandboxAll; | 40 SandboxFlags flags = kSandboxAll; |
| 41 unsigned length = policy.size(); | 41 unsigned length = policy.size(); |
| 42 unsigned number_of_token_errors = 0; | 42 unsigned number_of_token_errors = 0; |
| 43 StringBuilder token_errors; | 43 StringBuilder token_errors; |
| 44 | 44 |
| 45 for (unsigned index = 0; index < length; index++) { | 45 for (unsigned index = 0; index < length; index++) { |
| 46 // Turn off the corresponding sandbox flag if it's set as "allowed". | 46 // Turn off the corresponding sandbox flag if it's set as "allowed". |
| 47 String sandbox_token(policy[index]); | 47 String sandbox_token(policy[index]); |
| 48 if (EqualIgnoringCase(sandbox_token, "allow-same-origin")) { | 48 if (DeprecatedEqualIgnoringCase(sandbox_token, "allow-same-origin")) { |
| 49 flags &= ~kSandboxOrigin; | 49 flags &= ~kSandboxOrigin; |
| 50 } else if (EqualIgnoringCase(sandbox_token, "allow-forms")) { | 50 } else if (DeprecatedEqualIgnoringCase(sandbox_token, "allow-forms")) { |
| 51 flags &= ~kSandboxForms; | 51 flags &= ~kSandboxForms; |
| 52 } else if (EqualIgnoringCase(sandbox_token, "allow-scripts")) { | 52 } else if (DeprecatedEqualIgnoringCase(sandbox_token, "allow-scripts")) { |
| 53 flags &= ~kSandboxScripts; | 53 flags &= ~kSandboxScripts; |
| 54 flags &= ~kSandboxAutomaticFeatures; | 54 flags &= ~kSandboxAutomaticFeatures; |
| 55 } else if (EqualIgnoringCase(sandbox_token, "allow-top-navigation")) { | 55 } else if (DeprecatedEqualIgnoringCase(sandbox_token, |
| 56 "allow-top-navigation")) { |
| 56 flags &= ~kSandboxTopNavigation; | 57 flags &= ~kSandboxTopNavigation; |
| 57 } else if (EqualIgnoringCase(sandbox_token, "allow-popups")) { | 58 } else if (DeprecatedEqualIgnoringCase(sandbox_token, "allow-popups")) { |
| 58 flags &= ~kSandboxPopups; | 59 flags &= ~kSandboxPopups; |
| 59 } else if (EqualIgnoringCase(sandbox_token, "allow-pointer-lock")) { | 60 } else if (DeprecatedEqualIgnoringCase(sandbox_token, |
| 61 "allow-pointer-lock")) { |
| 60 flags &= ~kSandboxPointerLock; | 62 flags &= ~kSandboxPointerLock; |
| 61 } else if (EqualIgnoringCase(sandbox_token, "allow-orientation-lock")) { | 63 } else if (DeprecatedEqualIgnoringCase(sandbox_token, |
| 64 "allow-orientation-lock")) { |
| 62 flags &= ~kSandboxOrientationLock; | 65 flags &= ~kSandboxOrientationLock; |
| 63 } else if (EqualIgnoringCase(sandbox_token, | 66 } else if (DeprecatedEqualIgnoringCase(sandbox_token, |
| 64 "allow-popups-to-escape-sandbox")) { | 67 "allow-popups-to-escape-sandbox")) { |
| 65 flags &= ~kSandboxPropagatesToAuxiliaryBrowsingContexts; | 68 flags &= ~kSandboxPropagatesToAuxiliaryBrowsingContexts; |
| 66 } else if (EqualIgnoringCase(sandbox_token, "allow-modals")) { | 69 } else if (DeprecatedEqualIgnoringCase(sandbox_token, "allow-modals")) { |
| 67 flags &= ~kSandboxModals; | 70 flags &= ~kSandboxModals; |
| 68 } else if (EqualIgnoringCase(sandbox_token, "allow-presentation")) { | 71 } else if (DeprecatedEqualIgnoringCase(sandbox_token, |
| 72 "allow-presentation")) { |
| 69 flags &= ~kSandboxPresentation; | 73 flags &= ~kSandboxPresentation; |
| 70 } else if (EqualIgnoringCase(sandbox_token, | 74 } else if (DeprecatedEqualIgnoringCase( |
| 71 "allow-top-navigation-by-user-activation") && | 75 sandbox_token, "allow-top-navigation-by-user-activation") && |
| 72 RuntimeEnabledFeatures:: | 76 RuntimeEnabledFeatures:: |
| 73 topNavByUserActivationInSandboxEnabled()) { | 77 topNavByUserActivationInSandboxEnabled()) { |
| 74 flags &= ~kSandboxTopNavigationByUserActivation; | 78 flags &= ~kSandboxTopNavigationByUserActivation; |
| 75 } else { | 79 } else { |
| 76 token_errors.Append(token_errors.IsEmpty() ? "'" : ", '"); | 80 token_errors.Append(token_errors.IsEmpty() ? "'" : ", '"); |
| 77 token_errors.Append(sandbox_token); | 81 token_errors.Append(sandbox_token); |
| 78 token_errors.Append("'"); | 82 token_errors.Append("'"); |
| 79 number_of_token_errors++; | 83 number_of_token_errors++; |
| 80 } | 84 } |
| 81 } | 85 } |
| 82 | 86 |
| 83 if (number_of_token_errors) { | 87 if (number_of_token_errors) { |
| 84 token_errors.Append(number_of_token_errors > 1 | 88 token_errors.Append(number_of_token_errors > 1 |
| 85 ? " are invalid sandbox flags." | 89 ? " are invalid sandbox flags." |
| 86 : " is an invalid sandbox flag."); | 90 : " is an invalid sandbox flag."); |
| 87 invalid_tokens_error_message = token_errors.ToString(); | 91 invalid_tokens_error_message = token_errors.ToString(); |
| 88 } | 92 } |
| 89 | 93 |
| 90 return flags; | 94 return flags; |
| 91 } | 95 } |
| 92 | 96 |
| 93 } // namespace blink | 97 } // namespace blink |
| OLD | NEW |