dotnet / dotnet/aspnetcore

asp-append-version does not work with asp-src-include if globbing is used and file paths contain whitespace.

Open
#43,878 2 comments 0 reactions 0 assignees View on GitHub
area-mvc bug feature-mvc-razor-views
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Describe the bug

It seems that the FileVersionProvider that is invoked when using the "asp-append-version" doesn't like files returned via asp-src-include if such files contain whitespace.

``

This **does not work** when the filename/path contains whitespaces.

Directly referencing the path, however does work and includes a cache-bust version number.
Assume you have a file called **"/js/Library/My Javascript File.js"**.

The following works. It's got white space in the path, but it's referenced directly:
``
This will give you a referenced file and a file version string attached (e.g. "?v=23423425212").

However, the below _doesn't work_:
``
The file is referenced/included in the page output, but no append-version (e.g. "?v=323234234231") is attached.

This also _doesn't work_:
``
Here we are providing the src directly, but the whitespace is URL encoded to "%20". Same problem. The file referenced/included in the page output, but no append-version is attached.

The reason seems to be that `"src"` and `"asp-src-include"` return the file path(s) to the `FileVersionProvider` with whitespace being URL Encoded to "%20". But `PhysicalFileProvider` does not like that (you can't retrieve a file from the Operating System with `%20` in the path). Windows says no to "C:\Program%20Files\".

### Expected Behavior

Files included/referenced through globbed file patterns should be able to have version strings attached (through "asp-append-version") **even if they contain** whitespace.
Equally, files which are referenced as "~/myPath/My%20File%20name.css" should be able to have version strings attached even though the white space is URL encoded.

### Steps To Reproduce

_No response_

### Exceptions (if any)

_No response_

### .NET Version

6.0.100

### Anything else?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.