Skip to content

Media file cache busting version parameter won't be appended for files with spaces in their names with Azure storage #17985

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Piedone opened this issue Jun 6, 2025 · 1 comment

Comments

@Piedone
Copy link
Member

Piedone commented Jun 6, 2025

Describe the bug

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.

Orchard Core version

Current main 50b5992 but same on 2.1.7.

To Reproduce

  1. Enable and configure Azure Media Storage.
  2. Upload a file to the Media Library with spaces in its name, like My File With Space.jpg.
  3. Use @Orchard.AssetUrl("My File With Space.jpg", appendVersion: true) in a Razor template.
  4. 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.

This is because here:

var resolvedAssetPath = mediaFileStore.MapPathToPublicUrl(assetPath);

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:

fileInfo = fileProvider.GetFileInfo(resolvedPath);

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

Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants