From ae0d450e2e10c192671d9d041f9cf4d1cbb75dae Mon Sep 17 00:00:00 2001 From: Raymond LaRose Date: Wed, 28 May 2025 14:42:56 -0400 Subject: [PATCH] Refactor Invoke-GiteaFileDownload to replace URL encoded characters in file output path. Remove redundant unescaping of file name. --- PS-GiteaUtilities/PS-GiteaUtilities.psm1 | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/PS-GiteaUtilities/PS-GiteaUtilities.psm1 b/PS-GiteaUtilities/PS-GiteaUtilities.psm1 index 426b7f6..ce11cef 100644 --- a/PS-GiteaUtilities/PS-GiteaUtilities.psm1 +++ b/PS-GiteaUtilities/PS-GiteaUtilities.psm1 @@ -474,9 +474,6 @@ Function Invoke-GiteaFileDownload { # Replace any URL encoded characters in the file name $DownloadFileName = $pathSegments[-1] } - - $DownloadFilePath = [System.Uri]::UnescapeDataString($DownloadFilePath) - $DownloadFileName = [System.Uri]::UnescapeDataString($DownloadFileName) if ($PreserveRelativePath -and $outputPath) { # If PreserveRelativePath is used, set up the directory structure @@ -516,6 +513,8 @@ Function Invoke-GiteaFileDownload { # Normalize path separators $fileOutputPath = $fileOutputPath.Replace("/", [System.IO.Path]::DirectorySeparatorChar) + # Replace any URL encoded characters in the file output path + $fileOutputPath = [System.Uri]::UnescapeDataString($fileOutputPath) Write-Verbose "Output path: $fileOutputPath"