summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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;