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

Unified Diff: chrome/browser/chromeos/extensions/file_handler_util.cc

Issue 9700011: Convert file url to lowercase to make it match a file handler pattern. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More careful UTF8 handling 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
« no previous file with comments | « chrome/browser/chromeos/extensions/file_browser_private_api.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/extensions/file_handler_util.cc
diff --git a/chrome/browser/chromeos/extensions/file_handler_util.cc b/chrome/browser/chromeos/extensions/file_handler_util.cc
index 743f8c548cd5edbbddf5719ee1d67013a78625fb..969e9b6bfd4824b5adfe34efadeb64d8982afa5a 100644
--- a/chrome/browser/chromeos/extensions/file_handler_util.cc
+++ b/chrome/browser/chromeos/extensions/file_handler_util.cc
@@ -6,9 +6,11 @@
#include "base/bind.h"
#include "base/file_util.h"
+#include "base/i18n/case_conversion.h"
#include "base/json/json_writer.h"
#include "base/string_util.h"
#include "base/stringprintf.h"
+#include "base/utf_string_conversions.h"
#include "chrome/browser/extensions/extension_event_router.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_tab_util.h"
@@ -22,6 +24,7 @@
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/site_instance.h"
#include "content/public/browser/web_contents.h"
+#include "net/base/escape.h"
#include "webkit/fileapi/file_system_context.h"
#include "webkit/fileapi/file_system_mount_point_provider.h"
#include "webkit/fileapi/file_system_util.h"
@@ -95,6 +98,14 @@ URLPatternSet GetAllMatchingPatterns(const FileBrowserHandler* handler,
typedef std::set<const FileBrowserHandler*> ActionSet;
+std::string EscapedUtf8ToLower(const std::string& str) {
+ string16 utf16 = UTF8ToUTF16(
+ net::UnescapeURLComponent(str, net::UnescapeRule::NORMAL));
SeRya 2012/03/14 11:35:04 Looks suspicious. You are unescaping whole URL wit
Vladislav Kaznacheev 2012/03/14 12:24:43 Actually there is no net::UnescapeURL. The second
+ return net::EscapeUrlEncodedData(
+ UTF16ToUTF8(base::i18n::ToLower(utf16)),
+ false /* do not replace space with plus */);
+}
+
bool GetFileBrowserHandlers(Profile* profile,
const GURL& selected_file_url,
ActionSet* results) {
@@ -102,6 +113,11 @@ bool GetFileBrowserHandlers(Profile* profile,
if (!service)
return false; // In unit-tests, we may not have an ExtensionService.
+ // We need case-insensitive matching, and pattern in the handler is already
+ // in lower case.
+ const GURL lowercase_url(EscapedUtf8ToLower(selected_file_url.spec()));
+ LOG(ERROR) << lowercase_url.spec();
+
for (ExtensionSet::const_iterator iter = service->extensions()->begin();
iter != service->extensions()->end();
++iter) {
@@ -117,7 +133,7 @@ bool GetFileBrowserHandlers(Profile* profile,
action_iter != extension->file_browser_handlers()->end();
++action_iter) {
const FileBrowserHandler* action = action_iter->get();
- if (!action->MatchesURL(selected_file_url))
+ if (!action->MatchesURL(lowercase_url))
continue;
results->insert(action_iter->get());
« no previous file with comments | « chrome/browser/chromeos/extensions/file_browser_private_api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698