Skip to content

Commit 34d5bfc

Browse files
authored
Merge pull request #2115 from bcgov/bugfix/AB#32098-UrlEncoded
bufix/AB#32098 url endcoded file download
2 parents f4ed733 + a985bc7 commit 34d5bfc

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

applications/Unity.GrantManager/src/Unity.GrantManager.Application/Intakes/SubmissionAppService.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,12 @@ public async Task<BlobDto> GetChefsFileAttachment(Guid? formSubmissionId, Guid?
102102

103103
var contentBytes = response.Content != null ? await response.Content.ReadAsByteArrayAsync() : [];
104104
var contentType = response.Content?.Headers?.ContentType?.MediaType ?? "application/octet-stream";
105-
// if the file name is url encoded then decode it, otherwise return as is
106-
if (Uri.IsWellFormedUriString(name, UriKind.Absolute))
105+
// Check and decode the file name if it is URL encoded
106+
if (!string.IsNullOrEmpty(name) && name.Contains('%'))
107107
{
108-
name = Uri.UnescapeDataString(name);
108+
name = Uri.UnescapeDataString(name);
109109
}
110+
110111
return new BlobDto { Name = name, Content = contentBytes, ContentType = contentType };
111112
}
112113

0 commit comments

Comments
 (0)