-
Notifications
You must be signed in to change notification settings - Fork 334
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
Ampersand in folder name when browsing physical directory #306
Comments
That code is here: AspNetKatana/src/Microsoft.Owin.StaticFiles/DirectoryFormatters/HtmlDirectoryFormatter.cs Lines 115 to 138 in 569f1c8
It is HtmlEncoding the folder name via WebUtility: AspNetKatana/src/Microsoft.Owin.StaticFiles/DirectoryFormatters/HtmlDirectoryFormatter.cs Lines 152 to 155 in 569f1c8
Hmm, maybe that should be url encoded before html encoding it. Or the href portion and the display portion need to be encoded differently. Note this code also exists in Core. |
That said, '&' is a valid url path character. I wonder why it's being filtered. Looks like a common complaint: |
I have a website that utilizes physical directory browsing. Here's my code:
Everything's been working fine, until a user created a folder with an ampersand. The URL in the OWIN-generated directory-browsing page doesn't properly escape the ampersand (although it DOES appear to escape spaces, which is interesting). When a user clicks on the link, it results in an error.
Here's what the URL on the OWIN-generated directory-browsing page might look like:
http://localhost:1234/downloads/Phast/Phast%20&%20Safeti%208.11/
Notice the ampersand is NOT escaped.
The error in IIS is:
System.Web.HttpException:
A potentially dangerous Request.Path value was detected from the client (&).
My project targets .Net Framework 4.6.1
I'm using Microsoft.Owin Nuget packages with version 4.0.1
I suspect the fix for this will be to use System.Web.HttpUtility.UrlEncode for URLs, rather than ONLY escaping spaces.
The text was updated successfully, but these errors were encountered: