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

Unified Diff: extensions/browser/extension_user_script_loader.cc

Issue 2096433002: Convert prefix search in UserScript code to use base::StartsWith() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 | « no previous file | extensions/browser/web_ui_user_script_loader.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/extension_user_script_loader.cc
diff --git a/extensions/browser/extension_user_script_loader.cc b/extensions/browser/extension_user_script_loader.cc
index c4be84388a4eb8a3fe243b234123a4cc60adae9f..12e488e733ce4b0291db068c713012c6a3cfeb87 100644
--- a/extensions/browser/extension_user_script_loader.cc
+++ b/extensions/browser/extension_user_script_loader.cc
@@ -13,6 +13,7 @@
#include "base/bind_helpers.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
+#include "base/strings/string_util.h"
#include "base/version.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
@@ -102,11 +103,12 @@ bool LoadScriptContent(const HostID& host_id,
}
// Remove BOM from the content.
- std::string::size_type index = content.find(base::kUtf8ByteOrderMark);
- if (index == 0)
+ if (base::StartsWith(content, base::kUtf8ByteOrderMark,
+ base::CompareCase::SENSITIVE)) {
script_file->set_content(content.substr(strlen(base::kUtf8ByteOrderMark)));
- else
+ } else {
script_file->set_content(content);
+ }
return true;
}
« no previous file with comments | « no previous file | extensions/browser/web_ui_user_script_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698