Skip to content

Razor Class Library Static Assets with spaces do not resolve. #14999

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

Closed
gregfig opened this issue Oct 14, 2019 · 2 comments
Closed

Razor Class Library Static Assets with spaces do not resolve. #14999

gregfig opened this issue Oct 14, 2019 · 2 comments
Assignees
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates bug This issue describes a behavior which is not expected - a bug. Done This issue has been fixed

Comments

@gregfig
Copy link

gregfig commented Oct 14, 2019

If any files (images for example) contain a space. When they are coded with %20 they are not resolved.

To reproduce.

  1. Create a RCL with a wwwroot folder.
  2. Add one image file without a space, Add one image file with a space.
  3. Create a Web App and reference the RCL
  4. Run the app.

In my test app. https://localhost:44362/_content/RclTestCore3/MoneyBag.png resolves just fine.

However, https://localhost:44362/_content/RclTestCore3/Piggy Bank.png, which gets encoded as https://localhost:44362/_content/RclTestCore3/Piggy%20Bank.png, will return a 404 error.

I can workaround this by removing the spaces, but I happen to have a lot of images with spaces in their filenames.

Thanks

@javiercn javiercn added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Oct 15, 2019
@javiercn
Copy link
Member

javiercn commented Oct 15, 2019

@gregfig Thanks for contacting us.

I can repro this. The issue is in how the static file provider checks for the path, it reencoded the rest of the segments and passes down the encoded version to the underlying file provider.

image

The fix is to replace physicalPath with physicalPath.Value in https://github.com/aspnet/AspNetCore/blob/master/src/Hosting/Hosting/src/StaticWebAssets/StaticWebAssetsFileProvider.cs#L41-L64

@javiercn javiercn added the bug This issue describes a behavior which is not expected - a bug. label Oct 15, 2019
@javiercn
Copy link
Member

This is a 3.1 candidate

@mkArtakMSFT mkArtakMSFT added this to the 3.1.0-preview2 milestone Oct 15, 2019
@javiercn javiercn added Done This issue has been fixed and removed Working labels Oct 15, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Dec 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates bug This issue describes a behavior which is not expected - a bug. Done This issue has been fixed
Projects
None yet
Development

No branches or pull requests

3 participants