aspnetcore icon indicating copy to clipboard operation
aspnetcore copied to clipboard

Unescape relative path before file lookup to fix space-in-filename issue

Open jacob-l opened this issue 7 months ago • 5 comments

Summary

When serving files, if the requested path contains spaces or other special characters, the lookup fails because Uri.MakeRelativeUri returns a URL-encoded path (e.g. spaces become %20). The file provider expects a plain file path, not a URL-encoded one.

This PR adds a call to Uri.UnescapeDataString after MakeRelativeUri, ensuring the relative path is correctly unescaped before being used to retrieve files.

jacob-l avatar Jun 14 '25 06:06 jacob-l

Thanks for your PR, @@jacob-l. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@jacob-l thank you for your contribution. Could you, please add a test in https://github.com/dotnet/aspnetcore/blob/main/src/Components/WebView/WebView/test/StaticContentProviderTests.cs that would demonstrate the encoding failure you're describing?

ilonatommy avatar Jun 16 '25 06:06 ilonatommy

@dotnet-policy-service agree

jacob-l avatar Jun 16 '25 14:06 jacob-l

Thanks for your feedback and approval, @ilonatommy

jacob-l avatar Jun 16 '25 17:06 jacob-l

We also need security review, as unescaping has security implications.

javiercn avatar Jun 16 '25 17:06 javiercn

Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime. To make sure no conflicting changes have occurred, please rerun validation before merging. You can do this by leaving an /azp run comment here (requires commit rights), or by simply closing and reopening.