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

Unified Diff: chrome/common/extensions/extension.cc

Issue 7811006: Add full support for filesystem URLs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix merge errors Created 8 years, 9 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
Index: chrome/common/extensions/extension.cc
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
index ecf3d16338a5097749b3e7315a3a747e7167ba4a..d6b52f7a1f4ddfa0183bf86d24dff185b2217d69 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -2477,16 +2477,27 @@ FileBrowserHandler* Extension::LoadFileBrowserHandler(
return NULL;
}
StringToLowerASCII(&filter);
- URLPattern pattern(URLPattern::SCHEME_FILESYSTEM);
+ if (!StartsWithASCII(filter,
+ std::string(chrome::kFileSystemScheme) + ':',
+ true)) {
+ *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
+ errors::kInvalidURLPatternError, filter);
+ return NULL;
+ }
+ // The user inputs filesystem:*; we don't actually implement scheme
+ // wildcards in URLPattern, so transform to what will match correctly.
+ filter.replace(0, 11, "chrome-extension://*/");
+ URLPattern pattern(URLPattern::SCHEME_EXTENSION);
+ pattern.set_partial_filesystem_support_hack(true);
if (pattern.Parse(filter) != URLPattern::PARSE_SUCCESS) {
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
errors::kInvalidURLPatternError, filter);
return NULL;
}
std::string path = pattern.path();
- bool allowed = path == "*" || path == "*.*" ||
- (path.compare(0, 2, "*.") == 0 &&
- path.find_first_of('*', 2) == std::string::npos);
+ bool allowed = path == "/*" || path == "/*.*" ||
+ (path.compare(0, 3, "/*.") == 0 &&
+ path.find_first_of('*', 3) == std::string::npos);
if (!allowed) {
*error = ExtensionErrorUtils::FormatErrorMessageUTF16(
errors::kInvalidURLPatternError, filter);
« no previous file with comments | « chrome/common/content_settings_pattern_unittest.cc ('k') | chrome/common/extensions/extension_manifests_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698