OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2011, Google Inc. All rights reserved. | 2 * Copyright (C) 2011, Google Inc. All rights reserved. |
3 * Copyright (C) 2014, Samsung Electronics. All rights reserved. | 3 * Copyright (C) 2014, Samsung Electronics. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
102 StringBuilder builder; | 102 StringBuilder builder; |
103 unsigned length = scheme.length(); | 103 unsigned length = scheme.length(); |
104 for (unsigned i = 0; i < length; ++i) | 104 for (unsigned i = 0; i < length; ++i) |
105 builder.append(toASCIILower(scheme[i])); | 105 builder.append(toASCIILower(scheme[i])); |
106 | 106 |
107 return protocolWhitelist->contains(builder.toString()); | 107 return protocolWhitelist->contains(builder.toString()); |
108 } | 108 } |
109 | 109 |
110 static bool verifyProtocolHandlerScheme(const String& scheme, const String& meth od, ExceptionState& exceptionState) | 110 static bool verifyProtocolHandlerScheme(const String& scheme, const String& meth od, ExceptionState& exceptionState) |
111 { | 111 { |
112 if (scheme.startsWith("web+")) { | 112 if (!isValidProtocol(scheme)) { |
113 // The specification requires that the length of scheme is at least five characteres (including 'web+' prefix). | 113 exceptionState.throwDOMException(SyntaxError, "The scheme '" + scheme + "' is not valid protocol"); |
haraken
2014/06/23 13:47:16
Shouldn't this be a SecurityError instead of a DOM
gyuyoung-inactive
2014/06/24 05:09:56
Yes, SecurityError looks proper in this exception.
| |
114 if (scheme.length() >= 5 && isValidProtocol(scheme)) | |
115 return true; | |
116 if (!isValidProtocol(scheme)) | |
117 exceptionState.throwSecurityError("The scheme '" + scheme + "' is no t a valid protocol."); | |
118 else | |
119 exceptionState.throwSecurityError("The scheme '" + scheme + "' is le ss than five characters long."); | |
120 return false; | 114 return false; |
121 } | 115 } |
122 | 116 |
123 // The specification requires that schemes don't contain colons. | 117 if (scheme.startsWith("web+")) { |
124 size_t index = scheme.find(':'); | 118 // The specification requires that the length of scheme is at least five characteres (including 'web+' prefix). |
125 if (index != kNotFound) { | 119 if (scheme.length() >= 5) |
126 exceptionState.throwDOMException(SyntaxError, "The scheme '" + scheme + "' contains colon."); | 120 return true; |
haraken
2014/06/23 13:47:16
After this CL, this exception is merged with the S
gyuyoung-inactive
2014/06/24 05:09:56
Yes, I already added a test for this in r175104. I
| |
121 | |
122 exceptionState.throwSecurityError("The scheme '" + scheme + "' is less t han five characters long."); | |
127 return false; | 123 return false; |
128 } | 124 } |
129 | 125 |
130 if (isProtocolWhitelisted(scheme)) | 126 if (isProtocolWhitelisted(scheme)) |
131 return true; | 127 return true; |
132 exceptionState.throwSecurityError("The scheme '" + scheme + "' doesn't belon g to the protocol whitelist. Please prefix non-whitelisted schemes with the stri ng 'web+'."); | 128 exceptionState.throwSecurityError("The scheme '" + scheme + "' doesn't belon g to the protocol whitelist. Please prefix non-whitelisted schemes with the stri ng 'web+'."); |
133 return false; | 129 return false; |
134 } | 130 } |
135 | 131 |
136 NavigatorContentUtils* NavigatorContentUtils::from(Page& page) | 132 NavigatorContentUtils* NavigatorContentUtils::from(Page& page) |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
230 { | 226 { |
231 return "NavigatorContentUtils"; | 227 return "NavigatorContentUtils"; |
232 } | 228 } |
233 | 229 |
234 void provideNavigatorContentUtilsTo(Page& page, PassOwnPtr<NavigatorContentUtils Client> client) | 230 void provideNavigatorContentUtilsTo(Page& page, PassOwnPtr<NavigatorContentUtils Client> client) |
235 { | 231 { |
236 NavigatorContentUtils::provideTo(page, NavigatorContentUtils::supplementName (), NavigatorContentUtils::create(client)); | 232 NavigatorContentUtils::provideTo(page, NavigatorContentUtils::supplementName (), NavigatorContentUtils::create(client)); |
237 } | 233 } |
238 | 234 |
239 } // namespace WebCore | 235 } // namespace WebCore |
OLD | NEW |