Commit 7e94f53b authored by jochen@chromium.org's avatar jochen@chromium.org

Add protocolIsInHTTPFamily for strings and use it where appropriate

https://bugs.webkit.org/show_bug.cgi?id=127336

Reviewed by Alexey Proskuryakov.

* html/HTMLAnchorElement.cpp:
(WebCore::HTMLAnchorElement::parseAttribute):
* page/ContentSecurityPolicy.cpp:
(WebCore::CSPSource::schemeMatches):
* page/SecurityPolicy.cpp:
(WebCore::SecurityPolicy::generateReferrerHeader):
* platform/URL.cpp:
(WebCore::protocolIsInHTTPFamily):
* platform/URL.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@162555 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 747fe3bf
2014-01-22 Jochen Eisinger <jochen@chromium.org>
Add protocolIsInHTTPFamily for strings and use it where appropriate
https://bugs.webkit.org/show_bug.cgi?id=127336
Reviewed by Alexey Proskuryakov.
* html/HTMLAnchorElement.cpp:
(WebCore::HTMLAnchorElement::parseAttribute):
* page/ContentSecurityPolicy.cpp:
(WebCore::CSPSource::schemeMatches):
* page/SecurityPolicy.cpp:
(WebCore::SecurityPolicy::generateReferrerHeader):
* platform/URL.cpp:
(WebCore::protocolIsInHTTPFamily):
* platform/URL.h:
2014-01-22 Zalan Bujtas <zalan@apple.com>
Subpixel Layout: SimpleLineLayout needs more position rounding to match InlineFlowBox layout.
......@@ -251,7 +251,7 @@ void HTMLAnchorElement::parseAttribute(const QualifiedName& name, const AtomicSt
if (isLink()) {
String parsedURL = stripLeadingAndTrailingHTMLSpaces(value);
if (document().isDNSPrefetchEnabled()) {
if (protocolIs(parsedURL, "http") || protocolIs(parsedURL, "https") || parsedURL.startsWith("//"))
if (protocolIsInHTTPFamily(parsedURL) || parsedURL.startsWith("//"))
prefetchDNS(document().completeURL(parsedURL).host());
}
}
......
......@@ -260,7 +260,7 @@ private:
String protectedResourceScheme(m_policy->securityOrigin()->protocol());
#if ENABLE(CSP_NEXT)
if (equalIgnoringCase("http", protectedResourceScheme))
return url.protocolIs("http") || url.protocolIs("https");
return url.protocolIsInHTTPFamily();
#endif
return equalIgnoringCase(url.protocol(), protectedResourceScheme);
}
......
......@@ -71,7 +71,7 @@ String SecurityPolicy::generateReferrerHeader(ReferrerPolicy referrerPolicy, con
if (referrer.isEmpty())
return String();
if (!protocolIs(referrer, "http") && !protocolIs(referrer, "https"))
if (!protocolIsInHTTPFamily(referrer))
return String();
switch (referrerPolicy) {
......
......@@ -1775,6 +1775,16 @@ bool protocolIsJavaScript(const String& url)
return protocolIs(url, "javascript");
}
bool protocolIsInHTTPFamily(const String& url)
{
// Do the comparison without making a new string object.
return isLetterMatchIgnoringCase(url[0], 'h')
&& isLetterMatchIgnoringCase(url[1], 't')
&& isLetterMatchIgnoringCase(url[2], 't')
&& isLetterMatchIgnoringCase(url[3], 'p')
&& (url[4] == ':' || (isLetterMatchIgnoringCase(url[4], 's') && url[5] == ':'));
}
const URL& blankURL()
{
DEFINE_STATIC_LOCAL(URL, staticBlankURL, (ParsedURLString, "about:blank"));
......
......@@ -225,6 +225,7 @@ const URL& blankURL();
bool protocolIs(const String& url, const char* protocol);
bool protocolIsJavaScript(const String& url);
bool protocolIsInHTTPFamily(const String& url);
bool isDefaultPortForProtocol(unsigned short port, const String& protocol);
bool portAllowed(const URL&); // Blacklist ports that should never be used for Web resources.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment