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

Unified Diff: Source/modules/navigatorcontentutils/NavigatorContentUtils.cpp

Issue 349193002: Call isValidProtocol() function first in order to remove duplicated protocol checking in NavigatorC… (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/navigatorcontentutils/unregister-protocol-handler.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/navigatorcontentutils/NavigatorContentUtils.cpp
diff --git a/Source/modules/navigatorcontentutils/NavigatorContentUtils.cpp b/Source/modules/navigatorcontentutils/NavigatorContentUtils.cpp
index 9e7be6809d34fedd8bc9ff27eedcd7c969133cf2..fd82c34827ec94a8132f4f296d3c02f3278455e9 100644
--- a/Source/modules/navigatorcontentutils/NavigatorContentUtils.cpp
+++ b/Source/modules/navigatorcontentutils/NavigatorContentUtils.cpp
@@ -109,26 +109,23 @@ static bool isProtocolWhitelisted(const String& scheme)
static bool verifyProtocolHandlerScheme(const String& scheme, const String& method, ExceptionState& exceptionState)
{
+ if (!isValidProtocol(scheme)) {
+ exceptionState.throwSecurityError("The scheme '" + scheme + "' is not valid protocol");
+ return false;
+ }
+
if (scheme.startsWith("web+")) {
// The specification requires that the length of scheme is at least five characteres (including 'web+' prefix).
- if (scheme.length() >= 5 && isValidProtocol(scheme))
+ if (scheme.length() >= 5)
return true;
- if (!isValidProtocol(scheme))
- exceptionState.throwSecurityError("The scheme '" + scheme + "' is not a valid protocol.");
- else
- exceptionState.throwSecurityError("The scheme '" + scheme + "' is less than five characters long.");
- return false;
- }
- // The specification requires that schemes don't contain colons.
- size_t index = scheme.find(':');
- if (index != kNotFound) {
- exceptionState.throwDOMException(SyntaxError, "The scheme '" + scheme + "' contains colon.");
+ exceptionState.throwSecurityError("The scheme '" + scheme + "' is less than five characters long.");
return false;
}
if (isProtocolWhitelisted(scheme))
return true;
+
exceptionState.throwSecurityError("The scheme '" + scheme + "' doesn't belong to the protocol whitelist. Please prefix non-whitelisted schemes with the string 'web+'.");
return false;
}
« no previous file with comments | « LayoutTests/navigatorcontentutils/unregister-protocol-handler.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698