summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsr55 <[email protected]>2017-01-14 21:52:18 +0000
committersr55 <[email protected]>2017-01-14 21:52:18 +0000
commita9b099a4dda21b98fc9f2a5257298563ab52a55e (patch)
treebce155e657e069e99b3bcb1107e02ccb1695b5a9
parent37c850933585d8413e47142a197e642bd746c02a (diff)
WinGui: Fix erroneous path and filename handling. #515
-rw-r--r--win/CS/HandBrakeWPF/Helpers/FileHelper.cs14
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs12
2 files changed, 18 insertions, 8 deletions
diff --git a/win/CS/HandBrakeWPF/Helpers/FileHelper.cs b/win/CS/HandBrakeWPF/Helpers/FileHelper.cs
index e9017f8b5..f9d98e0a5 100644
--- a/win/CS/HandBrakeWPF/Helpers/FileHelper.cs
+++ b/win/CS/HandBrakeWPF/Helpers/FileHelper.cs
@@ -36,9 +36,17 @@ namespace HandBrakeWPF.Helpers
string file = Path.GetFileNameWithoutExtension(path);
string directory = Path.GetDirectoryName(path);
- // TODO this may not be necessary.
- if ((!string.IsNullOrEmpty(directory) && directory.Replace("\"", string.Empty).IndexOfAny(Path.GetInvalidPathChars()) != -1) ||
- file.Replace("\"", string.Empty).IndexOfAny(Path.GetInvalidFileNameChars()) != -1)
+ if (path.Split(':').Length - 1 > 1)
+ {
+ return true;
+ }
+
+ if (!string.IsNullOrEmpty(file) && file.Replace("\"", string.Empty).IndexOfAny(Path.GetInvalidPathChars()) != -1)
+ {
+ return true;
+ }
+
+ if (!string.IsNullOrEmpty(directory) && directory.Replace("\"", string.Empty).IndexOfAny(Path.GetInvalidPathChars()) != -1)
{
return true;
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
index 4dab47e0d..3454a5cbb 100644
--- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
@@ -709,14 +709,16 @@ namespace HandBrakeWPF.ViewModels
try
{
ext = Path.GetExtension(value);
+ if (FileHelper.FilePathHasInvalidChars(value) || string.IsNullOrEmpty(ext))
+ {
+ this.errorService.ShowMessageBox(Resources.Main_InvalidDestination, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
}
catch (ArgumentException)
{
- this.errorService.ShowMessageBox(
- Resources.Main_InvalidDestination,
- Resources.Error,
- MessageBoxButton.OK,
- MessageBoxImage.Error);
+ this.errorService.ShowMessageBox(Resources.Main_InvalidDestination, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
}
this.CurrentTask.Destination = value;