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.throwSecurityError("The scheme '" + scheme + "' is not va
lid protocol"); |
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; |
| 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; |
| 128 |
132 exceptionState.throwSecurityError("The scheme '" + scheme + "' doesn't belon
g to the protocol whitelist. Please prefix non-whitelisted schemes with the stri
ng 'web+'."); | 129 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; | 130 return false; |
134 } | 131 } |
135 | 132 |
136 NavigatorContentUtils* NavigatorContentUtils::from(Page& page) | 133 NavigatorContentUtils* NavigatorContentUtils::from(Page& page) |
137 { | 134 { |
138 return static_cast<NavigatorContentUtils*>(WillBeHeapSupplement<Page>::from(
page, supplementName())); | 135 return static_cast<NavigatorContentUtils*>(WillBeHeapSupplement<Page>::from(
page, supplementName())); |
139 } | 136 } |
140 | 137 |
141 NavigatorContentUtils::~NavigatorContentUtils() | 138 NavigatorContentUtils::~NavigatorContentUtils() |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 { | 227 { |
231 return "NavigatorContentUtils"; | 228 return "NavigatorContentUtils"; |
232 } | 229 } |
233 | 230 |
234 void provideNavigatorContentUtilsTo(Page& page, PassOwnPtr<NavigatorContentUtils
Client> client) | 231 void provideNavigatorContentUtilsTo(Page& page, PassOwnPtr<NavigatorContentUtils
Client> client) |
235 { | 232 { |
236 NavigatorContentUtils::provideTo(page, NavigatorContentUtils::supplementName
(), NavigatorContentUtils::create(client)); | 233 NavigatorContentUtils::provideTo(page, NavigatorContentUtils::supplementName
(), NavigatorContentUtils::create(client)); |
237 } | 234 } |
238 | 235 |
239 } // namespace WebCore | 236 } // namespace WebCore |
OLD | NEW |