Skip to content

Commit

Permalink
Fix playing video files with hash in the filename in Files.app.
Browse files Browse the repository at this point in the history
File names are passed via url. Because of faulty escaping, hash in the filename was causing interpreting part of the filename as url's hash part. This patch fixes it by properly escaping the hash character.

TEST=Play a local video with a hash character in the filename.
BUG=171987


Review URL: https://chromiumcodereview.appspot.com/12674003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@187276 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
mtomasz@chromium.org committed Mar 11, 2013
1 parent 4a560f9 commit 7b29be1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
20 changes: 14 additions & 6 deletions chrome/browser/chromeos/extensions/file_manager_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -405,14 +405,18 @@ void OpenFileBrowserImpl(const base::FilePath& path,
arg_value.SetString("action", action_id);
std::string query;
base::JSONWriter::Write(&arg_value, &query);
url += "?" + net::EscapeUrlEncodedData(query, false);
url += "?" +
net::EscapeUrlEncodedData(query,
false); // Space to %20 instead of +.
}
if (!path.empty()) {
base::FilePath virtual_path;
if (!ConvertFileToRelativeFileSystemPath(profile, kFileBrowserDomain, path,
&virtual_path))
return;
url += "#/" + net::EscapeUrlEncodedData(virtual_path.value(), false);
url += "#/" +
net::EscapeUrlEncodedData(virtual_path.value(),
false); // Space to %20 instead of +.
}

ExtensionService* service =
Expand Down Expand Up @@ -617,7 +621,9 @@ bool ConvertFileToFileSystemUrl(Profile* profile,

GURL base_url = fileapi::GetFileSystemRootURI(origin_url,
fileapi::kFileSystemTypeExternal);
*url = GURL(base_url.spec() + virtual_path.value());
*url = GURL(base_url.spec() +
net::EscapeUrlEncodedData(virtual_path.value(),
false)); // Space to %20 instead of +.
return true;
}

Expand Down Expand Up @@ -699,8 +705,9 @@ GURL GetFileBrowserUrlWithParams(

// kChromeUIFileManagerURL could not be used since query parameters are not
// supported for it.
std::string url = GetFileBrowserUrl().spec() +
'?' + net::EscapeUrlEncodedData(json_args, false);
std::string url = GetFileBrowserUrl().spec() + '?' +
net::EscapeUrlEncodedData(json_args,
false); // Space to %20 instead of +.
return GURL(url);
}

Expand Down Expand Up @@ -774,7 +781,8 @@ void OpenActionChoiceDialog(const base::FilePath& path) {
&virtual_path))
return;
std::string url = kActionChoiceUrl;
url += "#/" + net::EscapeUrlEncodedData(virtual_path.value(), false);
url += "#/" + net::EscapeUrlEncodedData(virtual_path.value(),
false); // Space to %20 instead of +.
GURL dialog_url(url);

const gfx::Size screen = ash::Shell::GetScreen()->GetPrimaryDisplay().size();
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/resources/file_manager/js/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ util.updateAppState = function(replace, path, opt_param) {

var hash;
if (path)
hash = '#' + encodeURI(path);
hash = '#' + encodeURIComponent(path);
else
hash = location.hash;

Expand Down

0 comments on commit 7b29be1

Please sign in to comment.