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

Side by Side Diff: chrome/browser/extensions/user_script_master.cc

Issue 420001: Ignore UTF-8's BOM when parsing userscript's metadata. (Closed)
Patch Set: Relect the review Created 11 years, 1 month 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 | « base/string_util.cc ('k') | chrome/browser/extensions/user_script_master_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/user_script_master.h" 5 #include "chrome/browser/extensions/user_script_master.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 28 matching lines...) Expand all
39 : master_(master) { 39 : master_(master) {
40 CHECK(ChromeThread::GetCurrentThreadIdentifier(&master_thread_id_)); 40 CHECK(ChromeThread::GetCurrentThreadIdentifier(&master_thread_id_));
41 } 41 }
42 42
43 // static 43 // static
44 bool UserScriptMaster::ScriptReloader::ParseMetadataHeader( 44 bool UserScriptMaster::ScriptReloader::ParseMetadataHeader(
45 const base::StringPiece& script_text, UserScript* script) { 45 const base::StringPiece& script_text, UserScript* script) {
46 // http://wiki.greasespot.net/Metadata_block 46 // http://wiki.greasespot.net/Metadata_block
47 base::StringPiece line; 47 base::StringPiece line;
48 size_t line_start = 0; 48 size_t line_start = 0;
49 size_t line_end = 0; 49
50 // Skip UTF-8's BOM.
51 if (script_text.starts_with(kUtf8ByteOrderMark))
52 line_start += strlen(kUtf8ByteOrderMark);
53
54 size_t line_end = line_start;
50 bool in_metadata = false; 55 bool in_metadata = false;
51 56
52 static const base::StringPiece kUserScriptBegin("// ==UserScript=="); 57 static const base::StringPiece kUserScriptBegin("// ==UserScript==");
53 static const base::StringPiece kUserScriptEng("// ==/UserScript=="); 58 static const base::StringPiece kUserScriptEng("// ==/UserScript==");
54 static const base::StringPiece kNamespaceDeclaration("// @namespace "); 59 static const base::StringPiece kNamespaceDeclaration("// @namespace ");
55 static const base::StringPiece kNameDeclaration("// @name "); 60 static const base::StringPiece kNameDeclaration("// @name ");
56 static const base::StringPiece kDescriptionDeclaration("// @description "); 61 static const base::StringPiece kDescriptionDeclaration("// @description ");
57 static const base::StringPiece kIncludeDeclaration("// @include "); 62 static const base::StringPiece kIncludeDeclaration("// @include ");
58 static const base::StringPiece kExcludeDeclaration("// @exclude "); 63 static const base::StringPiece kExcludeDeclaration("// @exclude ");
59 static const base::StringPiece kMatchDeclaration("// @match "); 64 static const base::StringPiece kMatchDeclaration("// @match ");
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 DCHECK(false); 396 DCHECK(false);
392 } 397 }
393 } 398 }
394 399
395 void UserScriptMaster::StartScan() { 400 void UserScriptMaster::StartScan() {
396 if (!script_reloader_) 401 if (!script_reloader_)
397 script_reloader_ = new ScriptReloader(this); 402 script_reloader_ = new ScriptReloader(this);
398 403
399 script_reloader_->StartScan(user_script_dir_, lone_scripts_); 404 script_reloader_->StartScan(user_script_dir_, lone_scripts_);
400 } 405 }
OLDNEW
« no previous file with comments | « base/string_util.cc ('k') | chrome/browser/extensions/user_script_master_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698