Skip to content

Commit 8537e65

Browse files
authored
Fix: Allow path with special chars (#1611)
* Fix: Path with special chars * Docs: Add #1611 * Fix: Only allow export for all results * Docs: Add #1611
1 parent 95d738a commit 8537e65

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

Source/NETworkManager.Utilities/RegexHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,6 @@ public static class RegexHelper
8585
public const string FilePath = @"^(?:[\w]\:|\\)(\\[a-z_\-\s0-9\.]+)+$";
8686

8787
// Match any fullname (like "c:\temp\test.txt") --> https://www.codeproject.com/Tips/216238/Regular-Expression-to-Validate-File-Path-and-Exten
88-
public const string FullName = @"^(?:[\w]\:|\\)(\\[a-z_\-\s0-9\.]+)+\.[a-zA-z0-9]{1,4}$";
88+
public const string FullName = @"^(?:[\w]\:|\\)(\\[a-zA-Z0-9_\-\s\.()~!@#$%^&=+';,{}\[\]]+)+\.[a-zA-z0-9]{1,4}$";
8989
}
9090
}

Source/NETworkManager/ViewModels/ExportViewModel.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,12 +293,12 @@ private void ChangeFilePathExtension(ExportManager.ExportFileType fileType)
293293

294294
var extension = Path.GetExtension(FilePath).Replace(".", "");
295295

296-
if (extension.Equals(ExportManager.GetFileExtensionAsString(fileType), StringComparison.CurrentCultureIgnoreCase))
297-
return;
296+
var newExtension = ExportManager.GetFileExtensionAsString(fileType);
298297

299-
FilePath = FilePath.Substring(0, FilePath.Length - extension.Length);
298+
if (extension.Equals(newExtension, StringComparison.CurrentCultureIgnoreCase))
299+
return;
300300

301-
FilePath += ExportManager.GetFileExtensionAsString(fileType).ToLower();
301+
FilePath = FilePath[..^extension.Length] + newExtension.ToLower();
302302
}
303303
}
304304
}

Source/NETworkManager/ViewModels/PingMonitorViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ public async Task Export()
307307

308308
SettingsManager.Current.PingMonitor_ExportFileType = instance.FileType;
309309
SettingsManager.Current.PingMonitor_ExportFilePath = instance.FilePath;
310-
}, instance => { _dialogCoordinator.HideMetroDialogAsync(this, customDialog); }, new ExportManager.ExportFileType[] { ExportManager.ExportFileType.CSV, ExportManager.ExportFileType.XML, ExportManager.ExportFileType.JSON }, true, SettingsManager.Current.PingMonitor_ExportFileType, SettingsManager.Current.PingMonitor_ExportFilePath);
310+
}, instance => { _dialogCoordinator.HideMetroDialogAsync(this, customDialog); }, new ExportManager.ExportFileType[] { ExportManager.ExportFileType.CSV, ExportManager.ExportFileType.XML, ExportManager.ExportFileType.JSON }, false, SettingsManager.Current.PingMonitor_ExportFileType, SettingsManager.Current.PingMonitor_ExportFilePath);
311311

312312
customDialog.Content = new ExportDialog
313313
{

docs/Changelog/next-release.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,16 @@ permalink: /Changelog/next-release
4747
- Handle null exception properly [#1510](https://github.com/BornToBeRoot/NETworkManager/pull/1510){:target="\_blank"}
4848
- Traceroute
4949
- Hops were skipped if they did not respond to ping [#1528](https://github.com/BornToBeRoot/NETworkManager/pull/1528){:target="\_blank"}
50+
- Ping Monitor
51+
- Allow export of all results only (hide other option in dialog as it has no effect) [#1611](https://github.com/BornToBeRoot/NETworkManager/pull/1611){:target="\_blank"}
5052
- Ping Monitor, Traceroute & SNMP
5153
- IPv6 is now resolved when selected in the settings [#1529](https://github.com/BornToBeRoot/NETworkManager/pull/1529){:target="\_blank"}
5254
- Remote Desktop, PowerShell, PuTTY & TigerVNC
5355
- "Unlock profile" dialog is now displayed correctly if an embedded window is already open [#1515](https://github.com/BornToBeRoot/NETworkManager/pull/1515){:target="\_blank"}
5456
- PowerShell & TigerVNC
5557
- Embedded window is now resized correctly after the inital connect [#1515](https://github.com/BornToBeRoot/NETworkManager/pull/1515){:target="\_blank"}
58+
- Export dialog
59+
- The "Export" button was disabled if the path contained special characters [#1611](https://github.com/BornToBeRoot/NETworkManager/pull/1611){:target="\_blank"}
5660
- Settings > Profiles
5761
- App crash fixed when a profile file is deleted and an encrypted but locked profile file is selected [#1512](https://github.com/BornToBeRoot/NETworkManager/pull/1512){:target="\_blank"}
5862
- Reselect group/profile on refresh (e.g. if profiles page is opened again) [#1516](https://github.com/BornToBeRoot/NETworkManager/pull/1516){:target="\_blank"}

0 commit comments

Comments
 (0)