 | CommonGetVerifiedPath Method |
Resolves a candidate file path and confirms it stays within the supplied base
directory, guarding against path-traversal. Throws when the path is missing,
malformed, or escapes the permitted directory.
Namespace:
IAS
Assembly:
Common (in Common.dll) Version: 1.0.0.0 (1.0.0.0)
Syntaxpublic static string GetVerifiedPath(
string baseDirectory,
string candidatePath
)
Public Shared Function GetVerifiedPath (
baseDirectory As String,
candidatePath As String
) As String
public static function GetVerifiedPath(
baseDirectory : String,
candidatePath : String
) : String
IAS.Common.GetVerifiedPath = function(baseDirectory, candidatePath);
Parameters
- baseDirectory
- Type: SystemString
The trusted root directory the path must stay within. - candidatePath
- Type: SystemString
The candidate path to validate and canonicalize.
Return Value
Type:
StringThe candidate path, unchanged, once verified as canonical and under the base directory.
See Also