Commit ca69c3d8 authored by Daniel Cheng's avatar Daniel Cheng Committed by Commit Bot

Use FindIgnoring{ASCIICase,Case} instead of using Find()'s third argument

When this is statically known at compile time, there's no need to do
dynamic dispatch.

Bug: 709815
Change-Id: I8cdd314d306c3b5557951b6bf94911be24c73d7a
Reviewed-on: https://chromium-review.googlesource.com/489642Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#468214}
parent d804e105
...@@ -175,7 +175,7 @@ bool DOMImplementation::IsJSONMIMEType(const String& mime_type) { ...@@ -175,7 +175,7 @@ bool DOMImplementation::IsJSONMIMEType(const String& mime_type) {
if (mime_type.StartsWith("application/json", kTextCaseASCIIInsensitive)) if (mime_type.StartsWith("application/json", kTextCaseASCIIInsensitive))
return true; return true;
if (mime_type.StartsWith("application/", kTextCaseASCIIInsensitive)) { if (mime_type.StartsWith("application/", kTextCaseASCIIInsensitive)) {
size_t subtype = mime_type.Find("+json", 12, kTextCaseASCIIInsensitive); size_t subtype = mime_type.FindIgnoringASCIICase("+json", 12);
if (subtype != kNotFound) { if (subtype != kNotFound) {
// Just check that a parameter wasn't matched. // Just check that a parameter wasn't matched.
size_t parameter_marker = mime_type.Find(";"); size_t parameter_marker = mime_type.Find(";");
......
...@@ -358,7 +358,7 @@ String ExtractCharset(const String& value) { ...@@ -358,7 +358,7 @@ String ExtractCharset(const String& value) {
unsigned length = value.length(); unsigned length = value.length();
while (pos < length) { while (pos < length) {
pos = value.Find(kCharsetString, pos, kTextCaseASCIIInsensitive); pos = value.FindIgnoringASCIICase(kCharsetString, pos);
if (pos == kNotFound) if (pos == kNotFound)
break; break;
......
...@@ -907,14 +907,12 @@ String XSSAuditor::CanonicalizedSnippetForJavaScript( ...@@ -907,14 +907,12 @@ String XSSAuditor::CanonicalizedSnippetForJavaScript(
bool XSSAuditor::IsContainedInRequest(const String& decoded_snippet) { bool XSSAuditor::IsContainedInRequest(const String& decoded_snippet) {
if (decoded_snippet.IsEmpty()) if (decoded_snippet.IsEmpty())
return false; return false;
if (decoded_url_.Find(decoded_snippet, 0, kTextCaseUnicodeInsensitive) != if (decoded_url_.FindIgnoringCase(decoded_snippet, 0) != kNotFound)
kNotFound)
return true; return true;
if (decoded_http_body_suffix_tree_ && if (decoded_http_body_suffix_tree_ &&
!decoded_http_body_suffix_tree_->MightContain(decoded_snippet)) !decoded_http_body_suffix_tree_->MightContain(decoded_snippet))
return false; return false;
return decoded_http_body_.Find(decoded_snippet, 0, return decoded_http_body_.FindIgnoringCase(decoded_snippet, 0) != kNotFound;
kTextCaseUnicodeInsensitive) != kNotFound;
} }
bool XSSAuditor::IsLikelySafeResource(const String& url) { bool XSSAuditor::IsLikelySafeResource(const String& url) {
......
...@@ -1009,14 +1009,13 @@ Response InspectorDOMAgent::performSearch( ...@@ -1009,14 +1009,13 @@ Response InspectorDOMAgent::performSearch(
AttributeCollection attributes = element->Attributes(); AttributeCollection attributes = element->Attributes();
for (auto& attribute : attributes) { for (auto& attribute : attributes) {
// Add attribute pair // Add attribute pair
if (attribute.LocalName().Find(whitespace_trimmed_query, 0, if (attribute.LocalName().FindIgnoringCase(whitespace_trimmed_query,
kTextCaseUnicodeInsensitive) != 0) != kNotFound) {
kNotFound) {
result_collector.insert(node); result_collector.insert(node);
break; break;
} }
size_t found_position = attribute.Value().Find( size_t found_position =
attribute_query, 0, kTextCaseUnicodeInsensitive); attribute.Value().FindIgnoringCase(attribute_query, 0);
if (found_position != kNotFound) { if (found_position != kNotFound) {
if (!exact_attribute_match || if (!exact_attribute_match ||
(!found_position && (!found_position &&
......
...@@ -305,8 +305,7 @@ bool ParseHTTPRefresh(const String& refresh, ...@@ -305,8 +305,7 @@ bool ParseHTTPRefresh(const String& refresh,
++pos; ++pos;
SkipWhiteSpace(refresh, pos, matcher); SkipWhiteSpace(refresh, pos, matcher);
unsigned url_start_pos = pos; unsigned url_start_pos = pos;
if (refresh.Find("url", url_start_pos, kTextCaseASCIIInsensitive) == if (refresh.FindIgnoringASCIICase("url", url_start_pos) == url_start_pos) {
url_start_pos) {
url_start_pos += 3; url_start_pos += 3;
SkipWhiteSpace(refresh, url_start_pos, matcher); SkipWhiteSpace(refresh, url_start_pos, matcher);
if (refresh[url_start_pos] == '=') { if (refresh[url_start_pos] == '=') {
...@@ -406,7 +405,7 @@ void FindCharsetInMediaType(const String& media_type, ...@@ -406,7 +405,7 @@ void FindCharsetInMediaType(const String& media_type,
unsigned length = media_type.length(); unsigned length = media_type.length();
while (pos < length) { while (pos < length) {
pos = media_type.Find("charset", pos, kTextCaseASCIIInsensitive); pos = media_type.FindIgnoringASCIICase("charset", pos);
if (pos == kNotFound || !pos) { if (pos == kNotFound || !pos) {
charset_len = 0; charset_len = 0;
return; return;
......
...@@ -41,7 +41,7 @@ String ContentType::Parameter(const String& parameter_name) const { ...@@ -41,7 +41,7 @@ String ContentType::Parameter(const String& parameter_name) const {
size_t semi = stripped_type.find(';'); size_t semi = stripped_type.find(';');
if (semi != kNotFound) { if (semi != kNotFound) {
size_t start = size_t start =
stripped_type.Find(parameter_name, semi + 1, kTextCaseASCIIInsensitive); stripped_type.FindIgnoringASCIICase(parameter_name, semi + 1);
if (start != kNotFound) { if (start != kNotFound) {
start = stripped_type.find('=', start + parameter_name.length()); start = stripped_type.find('=', start + parameter_name.length());
if (start != kNotFound) { if (start != kNotFound) {
......
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