mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 18:21:10 +00:00
Merge pull request #17 from BinaryAlley/bugfix/fix-file-system-path-check-regex
Fixes paths regex checks not recognizing [ and ]
This commit is contained in:
2 files changed
+4
-4
No files matched your search
+2
-2
@@ -50,8 +50,8 @@ public class UnixPathStrategy : IUnixPathStrategy
|
|||||||
// check for relative paths
|
// check for relative paths
|
||||||
if (path.Path.StartsWith("./") || path.Path.StartsWith("../"))
|
if (path.Path.StartsWith("./") || path.Path.StartsWith("../"))
|
||||||
return false;
|
return false;
|
||||||
string pathPattern = @"^\/([\w\-\.\~!$&'()*+,;=:@ ]+(\/[\w\-\.\~!$&'()*+,;=:@ ]+)*)?\/?$";
|
const string PATH_PATTERN = @"^\/([\w\-\.\~!$&'()*+,;=:@\[\] ]+(\/[\w\-\.\~!$&'()*+,;=:@\[\] ]+)*)?\/?$";
|
||||||
return Regex.IsMatch(path.Path, pathPattern);
|
return Regex.IsMatch(path.Path, PATH_PATTERN);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
+2
-2
@@ -49,8 +49,8 @@ public class WindowsPathStrategy : IWindowsPathStrategy
|
|||||||
return false;
|
return false;
|
||||||
// regular expression to match valid absolute paths
|
// regular expression to match valid absolute paths
|
||||||
// this allows drive letters (e.g., C:\) and UNC paths (e.g., \\server\share)
|
// this allows drive letters (e.g., C:\) and UNC paths (e.g., \\server\share)
|
||||||
string pathPattern = @"^(?:[a-zA-Z]:\\|\\\\[a-zA-Z0-9\s()._-]+\\[a-zA-Z0-9\s()._-]+)(?:[a-zA-Z0-9\s()._-]+\\)*[a-zA-Z0-9\s()._-]*\\?$";
|
const string PATH_PATTERN = @"^(?:[a-zA-Z]:\\|\\\\[a-zA-Z0-9\s()._\[\]-]+\\[a-zA-Z0-9\s()._\[\]-]+)(?:[a-zA-Z0-9\s()._\[\]-]+\\)*[a-zA-Z0-9\s()._\[\]-]*\\?$";
|
||||||
return Regex.IsMatch(path.Path, pathPattern);
|
return Regex.IsMatch(path.Path, PATH_PATTERN);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in new issue
Block a user