Added code to sanitize folder path (#2673)

This commit is contained in:
Divyansh Srivastava 2020-05-05 09:41:11 -07:00 committed by GitHub
parent 64c17767ed
commit 67b2f28064
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using Wox.Infrastructure; using Wox.Infrastructure;
@ -255,6 +256,7 @@ namespace Microsoft.Plugin.Folder
var firstResult = "Open " + search; var firstResult = "Open " + search;
var folderName = search.TrimEnd('\\').Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.None).Last(); var folderName = search.TrimEnd('\\').Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.None).Last();
var sanitizedPath = Regex.Replace(search, @"[\/\\]+", "\\");
return new Result return new Result
{ {
@ -265,7 +267,7 @@ namespace Microsoft.Plugin.Folder
Score = 500, Score = 500,
Action = c => Action = c =>
{ {
Process.Start(_fileExplorerProgramName, search); Process.Start(_fileExplorerProgramName, sanitizedPath);
return true; return true;
} }
}; };