Commit c5a6c38d authored by Klemen Kozjek's avatar Klemen Kozjek Committed by Commit Bot

Files App: Sanitize disk mount point names

Before the CL, in case when external removable drive had '#' character
in its name it caused that disk was not accessible through Files App.
The user was able to select the drive, but no content was displayed
neither they were able to add new files to the drive.

This CL sanitizes and suggests mount point names for all mountable
drives to prevent mounting a device with '#' in its name.

Bug: 774241

Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: I90e5808bb0d8b4a26becaf9ba30b538ce580b3dd
Reviewed-on: https://chromium-review.googlesource.com/720639Reviewed-by: default avatarTatsuhisa Yamaguchi <yamaguchi@chromium.org>
Reviewed-by: default avatarNaoki Fukino <fukino@chromium.org>
Commit-Queue: Klemen Kozjek <klemenko@google.com>
Cr-Commit-Position: refs/heads/master@{#509325}
parent 91fcb1ca
......@@ -550,14 +550,19 @@ void VolumeManager::OnDiskEvent(
bool mounting = false;
if (disk->mount_path().empty() && disk->has_media() &&
!profile_->GetPrefs()->GetBoolean(prefs::kExternalStorageDisabled)) {
// TODO(crbug.com/774890): Remove |mount_label| when the issue gets
// resolved. Currently we suggest a mount point name, because in case
// when disk's name contains '#', content will not load in Files App.
std::string mount_label = disk->device_label();
std::replace(mount_label.begin(), mount_label.end(), '#', '_');
// If disk is not mounted yet and it has media and there is no policy
// forbidding external storage, give it a try.
// Initiate disk mount operation. MountPath auto-detects the filesystem
// format if the second argument is empty. The third argument (mount
// label) is not used in a disk mount operation.
disk_mount_manager_->MountPath(disk->device_path(), std::string(),
std::string(),
chromeos::MOUNT_TYPE_DEVICE,
mount_label, chromeos::MOUNT_TYPE_DEVICE,
GetExternalStorageAccessMode(profile_));
mounting = true;
}
......
......@@ -135,11 +135,7 @@ DirectoryTreeNamingController.prototype.commitRename_ = function() {
if (this.isRemovableRoot_) {
// Validate new name.
new Promise(entry.getParent.bind(entry))
.then(function(parentEntry) {
return util.validateExternalDriveName(
newName, assert(this.volumeInfo_));
}.bind(this))
util.validateExternalDriveName(newName, assert(this.volumeInfo_))
.then(
this.performExternalDriveRename_.bind(this, entry, newName),
function(errorMessage) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment