diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-11 20:42:31 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-11 20:42:31 +0000 |
commit | 60f0c4072e004002b87a25f6e5681557848d3060 (patch) | |
tree | 78214e53483388daafd818499f710fd656861290 /chrome/browser/extensions/user_script_master.cc | |
parent | cc70801856ea67a98ac0ff0b9064a6b56e67288d (diff) | |
download | chromium_src-60f0c4072e004002b87a25f6e5681557848d3060.zip chromium_src-60f0c4072e004002b87a25f6e5681557848d3060.tar.gz chromium_src-60f0c4072e004002b87a25f6e5681557848d3060.tar.bz2 |
Fix a bug where we don't recognize user script declarations
if they aren't at the beginning of a line. Greasemonkey
allows this.
BUG=31076
TEST=Install http://userscripts.org/scripts/review/29876. The
install dialog should say 'Sans-serif default', not
29876.user.js.
Review URL: http://codereview.chromium.org/545002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35938 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/user_script_master.cc')
-rw-r--r-- | chrome/browser/extensions/user_script_master.cc | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/chrome/browser/extensions/user_script_master.cc b/chrome/browser/extensions/user_script_master.cc index 528f1b9..d142e0a 100644 --- a/chrome/browser/extensions/user_script_master.cc +++ b/chrome/browser/extensions/user_script_master.cc @@ -26,11 +26,16 @@ static bool GetDeclarationValue(const base::StringPiece& line, const base::StringPiece& prefix, std::string* value) { - if (!line.starts_with(prefix)) + base::StringPiece::size_type index = line.find(prefix); + if (index == base::StringPiece::npos) + return false; + + std::string temp(line.data() + index + prefix.length(), + line.length() - index - prefix.length()); + + if (temp.size() == 0 || !IsWhitespace(temp[0])) return false; - std::string temp(line.data() + prefix.length(), - line.length() - prefix.length()); TrimWhitespaceASCII(temp, TRIM_ALL, value); return true; } @@ -56,13 +61,13 @@ bool UserScriptMaster::ScriptReloader::ParseMetadataHeader( static const base::StringPiece kUserScriptBegin("// ==UserScript=="); static const base::StringPiece kUserScriptEng("// ==/UserScript=="); - static const base::StringPiece kNamespaceDeclaration("// @namespace "); - static const base::StringPiece kNameDeclaration("// @name "); - static const base::StringPiece kDescriptionDeclaration("// @description "); - static const base::StringPiece kIncludeDeclaration("// @include "); - static const base::StringPiece kExcludeDeclaration("// @exclude "); - static const base::StringPiece kMatchDeclaration("// @match "); - static const base::StringPiece kRunAtDeclaration("// @run-at "); + static const base::StringPiece kNamespaceDeclaration("// @namespace"); + static const base::StringPiece kNameDeclaration("// @name"); + static const base::StringPiece kDescriptionDeclaration("// @description"); + static const base::StringPiece kIncludeDeclaration("// @include"); + static const base::StringPiece kExcludeDeclaration("// @exclude"); + static const base::StringPiece kMatchDeclaration("// @match"); + static const base::StringPiece kRunAtDeclaration("// @run-at"); static const base::StringPiece kRunAtDocumentStartValue("document-start"); static const base::StringPiece kRunAtDocumentEndValue("document-end"); |