summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/user_script_master.cc
diff options
context:
space:
mode:
authorhayato@chromium.org <hayato@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-25 04:23:02 +0000
committerhayato@chromium.org <hayato@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-25 04:23:02 +0000
commitd09ef157bb44612d1bcd1bfe4e5fa26e1aaf0408 (patch)
tree28c7cfef4167ffddce1fcd0ebacc4ab83b5b33c9 /chrome/browser/extensions/user_script_master.cc
parent922dea0e0c86de952ae962127d3115234e277854 (diff)
downloadchromium_src-d09ef157bb44612d1bcd1bfe4e5fa26e1aaf0408.zip
chromium_src-d09ef157bb44612d1bcd1bfe4e5fa26e1aaf0408.tar.gz
chromium_src-d09ef157bb44612d1bcd1bfe4e5fa26e1aaf0408.tar.bz2
Ignore UTF-8's BOM when parsing userscript's metadata.
BUG=27333 TEST=UserScriptTest and check the issue does not happen against userscipt encoded in UTF-8 with BOM.. Review URL: http://codereview.chromium.org/420001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33048 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/user_script_master.cc')
-rw-r--r--chrome/browser/extensions/user_script_master.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/chrome/browser/extensions/user_script_master.cc b/chrome/browser/extensions/user_script_master.cc
index c9228ff..a485a41 100644
--- a/chrome/browser/extensions/user_script_master.cc
+++ b/chrome/browser/extensions/user_script_master.cc
@@ -46,7 +46,12 @@ bool UserScriptMaster::ScriptReloader::ParseMetadataHeader(
// http://wiki.greasespot.net/Metadata_block
base::StringPiece line;
size_t line_start = 0;
- size_t line_end = 0;
+
+ // Skip UTF-8's BOM.
+ if (script_text.starts_with(kUtf8ByteOrderMark))
+ line_start += strlen(kUtf8ByteOrderMark);
+
+ size_t line_end = line_start;
bool in_metadata = false;
static const base::StringPiece kUserScriptBegin("// ==UserScript==");