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

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

Issue 323493003: Scheme of content utils should be compared in an ASCII case-insensitive manner (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-expected.txt ('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) 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 16 matching lines...) Expand all
27 #include "config.h" 27 #include "config.h"
28 #include "modules/navigatorcontentutils/NavigatorContentUtils.h" 28 #include "modules/navigatorcontentutils/NavigatorContentUtils.h"
29 29
30 #include "bindings/v8/ExceptionState.h" 30 #include "bindings/v8/ExceptionState.h"
31 #include "core/dom/Document.h" 31 #include "core/dom/Document.h"
32 #include "core/dom/ExceptionCode.h" 32 #include "core/dom/ExceptionCode.h"
33 #include "core/frame/LocalFrame.h" 33 #include "core/frame/LocalFrame.h"
34 #include "core/frame/Navigator.h" 34 #include "core/frame/Navigator.h"
35 #include "core/page/Page.h" 35 #include "core/page/Page.h"
36 #include "wtf/HashSet.h" 36 #include "wtf/HashSet.h"
37 #include "wtf/text/StringBuilder.h"
37 38
38 namespace WebCore { 39 namespace WebCore {
39 40
40 static HashSet<String>* protocolWhitelist; 41 static HashSet<String>* protocolWhitelist;
41 42
42 static void initProtocolHandlerWhitelist() 43 static void initProtocolHandlerWhitelist()
43 { 44 {
44 protocolWhitelist = new HashSet<String>; 45 protocolWhitelist = new HashSet<String>;
45 static const char* const protocols[] = { 46 static const char* const protocols[] = {
46 "bitcoin", 47 "bitcoin",
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 return false; 91 return false;
91 } 92 }
92 93
93 return true; 94 return true;
94 } 95 }
95 96
96 static bool isProtocolWhitelisted(const String& scheme) 97 static bool isProtocolWhitelisted(const String& scheme)
97 { 98 {
98 if (!protocolWhitelist) 99 if (!protocolWhitelist)
99 initProtocolHandlerWhitelist(); 100 initProtocolHandlerWhitelist();
100 return protocolWhitelist->contains(scheme); 101
102 StringBuilder builder;
103 unsigned length = scheme.length();
104 for (unsigned i = 0; i < length; ++i)
105 builder.append(toASCIILower(scheme[i]));
106
107 return protocolWhitelist->contains(builder.toString());
101 } 108 }
102 109
103 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)
104 { 111 {
105 if (scheme.startsWith("web+")) { 112 if (scheme.startsWith("web+")) {
106 // The specification requires that the length of scheme is at least five characteres (including 'web+' prefix). 113 // The specification requires that the length of scheme is at least five characteres (including 'web+' prefix).
107 if (scheme.length() >= 5 && isValidProtocol(scheme)) 114 if (scheme.length() >= 5 && isValidProtocol(scheme))
108 return true; 115 return true;
109 if (!isValidProtocol(scheme)) 116 if (!isValidProtocol(scheme))
110 exceptionState.throwSecurityError("The scheme '" + scheme + "' is no t a valid protocol."); 117 exceptionState.throwSecurityError("The scheme '" + scheme + "' is no t a valid protocol.");
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 { 230 {
224 return "NavigatorContentUtils"; 231 return "NavigatorContentUtils";
225 } 232 }
226 233
227 void provideNavigatorContentUtilsTo(Page& page, PassOwnPtr<NavigatorContentUtils Client> client) 234 void provideNavigatorContentUtilsTo(Page& page, PassOwnPtr<NavigatorContentUtils Client> client)
228 { 235 {
229 NavigatorContentUtils::provideTo(page, NavigatorContentUtils::supplementName (), NavigatorContentUtils::create(client)); 236 NavigatorContentUtils::provideTo(page, NavigatorContentUtils::supplementName (), NavigatorContentUtils::create(client));
230 } 237 }
231 238
232 } // namespace WebCore 239 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/fast/dom/navigatorcontentutils/unregister-protocol-handler-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698