]> granicus.if.org Git - handbrake/commitdiff
WinGui: Fix erroneous path and filename handling. #515
authorsr55 <sr55.hb@outlook.com>
Sat, 14 Jan 2017 21:52:18 +0000 (21:52 +0000)
committersr55 <sr55.hb@outlook.com>
Sat, 14 Jan 2017 21:52:42 +0000 (21:52 +0000)
win/CS/HandBrakeWPF/Helpers/FileHelper.cs
win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs

index e9017f8b5849cc8d3055e9bc697f0132ea6ec295..f9d98e0a5a7a8b7603b5a52a41933e80fcce2956 100644 (file)
@@ -36,9 +36,17 @@ namespace HandBrakeWPF.Helpers
                     string file = Path.GetFileNameWithoutExtension(path);\r
                     string directory = Path.GetDirectoryName(path);\r
 \r
-                    // TODO this may not be necessary.\r
-                    if ((!string.IsNullOrEmpty(directory) && directory.Replace("\"", string.Empty).IndexOfAny(Path.GetInvalidPathChars()) != -1) ||\r
-                        file.Replace("\"", string.Empty).IndexOfAny(Path.GetInvalidFileNameChars()) != -1)\r
+                    if (path.Split(':').Length - 1 > 1)\r
+                    {\r
+                        return true;\r
+                    }\r
+\r
+                    if (!string.IsNullOrEmpty(file) && file.Replace("\"", string.Empty).IndexOfAny(Path.GetInvalidPathChars()) != -1)\r
+                    {\r
+                        return true;\r
+                    }\r
+\r
+                    if (!string.IsNullOrEmpty(directory) && directory.Replace("\"", string.Empty).IndexOfAny(Path.GetInvalidPathChars()) != -1)\r
                     {\r
                         return true;\r
                     }\r
index 4dab47e0df51f4caf1378da298ff077d2cdbeb78..3454a5cbbe4492d0cc0bb55b4ecc42f8328f4f42 100644 (file)
@@ -709,14 +709,16 @@ namespace HandBrakeWPF.ViewModels
                         try\r
                         {\r
                             ext = Path.GetExtension(value);\r
+                            if (FileHelper.FilePathHasInvalidChars(value) || string.IsNullOrEmpty(ext))\r
+                            {\r
+                                this.errorService.ShowMessageBox(Resources.Main_InvalidDestination, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);\r
+                                return;\r
+                            }\r
                         }\r
                         catch (ArgumentException)\r
                         {\r
-                            this.errorService.ShowMessageBox(\r
-                                Resources.Main_InvalidDestination,\r
-                                Resources.Error,\r
-                                MessageBoxButton.OK,\r
-                                MessageBoxImage.Error);\r
+                            this.errorService.ShowMessageBox(Resources.Main_InvalidDestination, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);\r
+                            return;\r
                         }\r
 \r
                         this.CurrentTask.Destination = value;\r