Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: Source/modules/navigatorcontentutils/NavigatorContentUtils.cpp

Issue 298273008: Improve scheme validation check in NavigatorContentUtils (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « LayoutTests/fast/dom/navigatorcontentutils/unregister-protocol-handler.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, Google Inc. All rights reserved. 2 * Copyright (C) 2011, Google Inc. All rights reserved.
3 * Copyright (C) 2012, Samsung Electronics. All rights reserved. 3 * Copyright (C) 2012, 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 // The specification requires that the length of scheme is at least five characteres (including 'web+' prefix). 106 // The specification requires that the length of scheme is at least five characteres (including 'web+' prefix).
107 if (scheme.length() >= 5 && isValidProtocol(scheme)) 107 if (scheme.length() >= 5 && isValidProtocol(scheme))
108 return true; 108 return true;
109 if (!isValidProtocol(scheme)) 109 if (!isValidProtocol(scheme))
110 exceptionState.throwSecurityError("The scheme '" + scheme + "' is no t a valid protocol."); 110 exceptionState.throwSecurityError("The scheme '" + scheme + "' is no t a valid protocol.");
111 else 111 else
112 exceptionState.throwSecurityError("The scheme '" + scheme + "' is le ss than five characters long."); 112 exceptionState.throwSecurityError("The scheme '" + scheme + "' is le ss than five characters long.");
113 return false; 113 return false;
114 } 114 }
115 115
116 // The specification requires that schemes don't contain colons.
117 size_t index = scheme.find(':');
118 if (index != kNotFound) {
119 exceptionState.throwDOMException(SyntaxError, "The scheme '" + scheme + "' contains colon.");
120 return false;
121 }
122
116 if (isProtocolWhitelisted(scheme)) 123 if (isProtocolWhitelisted(scheme))
117 return true; 124 return true;
118 exceptionState.throwSecurityError("The scheme '" + scheme + "' doesn't belon g to the protocol whitelist. Please prefix non-whitelisted schemes with the stri ng 'web+'."); 125 exceptionState.throwSecurityError("The scheme '" + scheme + "' doesn't belon g to the protocol whitelist. Please prefix non-whitelisted schemes with the stri ng 'web+'.");
119 return false; 126 return false;
120 } 127 }
121 128
122 NavigatorContentUtils* NavigatorContentUtils::from(Page& page) 129 NavigatorContentUtils* NavigatorContentUtils::from(Page& page)
123 { 130 {
124 return static_cast<NavigatorContentUtils*>(WillBeHeapSupplement<Page>::from( page, supplementName())); 131 return static_cast<NavigatorContentUtils*>(WillBeHeapSupplement<Page>::from( page, supplementName()));
125 } 132 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 { 223 {
217 return "NavigatorContentUtils"; 224 return "NavigatorContentUtils";
218 } 225 }
219 226
220 void provideNavigatorContentUtilsTo(Page& page, PassOwnPtr<NavigatorContentUtils Client> client) 227 void provideNavigatorContentUtilsTo(Page& page, PassOwnPtr<NavigatorContentUtils Client> client)
221 { 228 {
222 NavigatorContentUtils::provideTo(page, NavigatorContentUtils::supplementName (), NavigatorContentUtils::create(client)); 229 NavigatorContentUtils::provideTo(page, NavigatorContentUtils::supplementName (), NavigatorContentUtils::create(client));
223 } 230 }
224 231
225 } // namespace WebCore 232 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/fast/dom/navigatorcontentutils/unregister-protocol-handler.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698