You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using IFileVersionProvider.AddFileVersionToPath() (like from Orchard.AssetUrl()), the cache busting v parameter won't be appended for files with spaces in their names, and potentially other special characters either.
Upload a file to the Media Library with spaces in its name, like My File With Space.jpg.
Use @Orchard.AssetUrl("My File With Space.jpg", appendVersion: true) in a Razor template.
Observe that the generated URL (even after first accessing the file, i.e. it being cached in the App_Data folder) will be /media/My%20File%20With%20Space.jpg, i.e. it doesn't contain the v parameter.
the path will be resolved to /media/My%20File%20With%20Space.jpg. Note that this is a URL, though (expected from MapPathToPublicUrl) but used as a path, which is incorrect. Once control reaches here:
We triaged this issue and set the milestone according to the priority we think is appropriate (see the docs on how we triage and prioritize issues).
This indicates when the core team may start working on it. However, if you'd like to contribute, we'd warmly welcome you to do that anytime. See our guide on contributions here.
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug
When using
IFileVersionProvider.AddFileVersionToPath()
(like fromOrchard.AssetUrl()
), the cache bustingv
parameter won't be appended for files with spaces in their names, and potentially other special characters either.Orchard Core version
Current
main
50b5992 but same on 2.1.7.To Reproduce
My File With Space.jpg
.@Orchard.AssetUrl("My File With Space.jpg", appendVersion: true)
in a Razor template.App_Data
folder) will be/media/My%20File%20With%20Space.jpg
, i.e. it doesn't contain thev
parameter.This is because here:
OrchardCore/src/OrchardCore.Modules/OrchardCore.Media/Razor/OrchardRazorHelperExtensions.cs
Line 28 in 50b5992
the path will be resolved to
/media/My%20File%20With%20Space.jpg
. Note that this is a URL, though (expected fromMapPathToPublicUrl
) but used as a path, which is incorrect. Once control reaches here:OrchardCore/src/OrchardCore/OrchardCore.Mvc.Core/ShellFileVersionProvider.cs
Line 101 in 50b5992
The path should rather be
My File With Space.jpg
, without encoding. That path works. Not sure where to fix this.While I only tested this with Azure storage, due to this being related to local file caching, most possibly AWS is also affected.
#17764 looks related, or perhaps even the same.
Expected behavior
The generated URL is something like
/media/My%20File%20With%20Space.jpg?v=SmVczkfAnA8oUKX7YxbM-NPhv3HaI8rt7fHDC0tNyB4
.Logs and screenshots
The text was updated successfully, but these errors were encountered: