-
Notifications
You must be signed in to change notification settings - Fork 72
Invalid characters in the request URL causes an ArgumentException to be raised #84
Comments
Wondering if we should check for invalid path characters as part of the The odd thing is the log output would be "The request path {Path} does not match the path filter". I have an feeling I might have misunderstood the purpose of the method due to the log output if it returns |
I wanted to take a whack at fixing this issue, but I think the solution might warrant some discussion. For example, do we strip invalid characters from the request in the static file middleware? Do we check for invalid characters in I'd want to try and avoid sticking try/catches around the methods as we get a lot of first chance exceptions happening, potentially pausing the debugger, etc. Invalid characters aren’t exceptional, we should try to detect the problem and handle it gracefully. |
Let me know if that potential solution is good enough for a pull request. I've renamed the existing |
Related: aspnet/FileSystem#147 |
Just looked through that issue @Tratcher, and I agree with @davidfowl; they're kinda related in that they're both trying to deal with odd characters, but I think both issues need their separate fixes. Let me know if https://github.com/brentnewbury/StaticFiles/commit/11e02d1a513f41a8dc704027dd6a50e25f64054e seems like a good candidate for a pull request and I'll create one. |
Yes! @brentnewbury do send a pull request for your change. The only thing I'm not sure about is if the static file handler should pass through to the next middleware. I could see that being ok though. |
I let it pass through so that other middleware can try to handle it, better to passthrough than to swallow it up. Maybe in the future, if it's asked for, we could make it optional. I'll submit that pr now. |
A request with invalid characters (e.g.
/%3C
[edit] which is URL decoded to<
) causes anArgumentException
to be raised. This produces an HTTP 500 error to be returned to the client, rather than the expected HTTP 404.Below if the stack trace from the exception:
The text was updated successfully, but these errors were encountered: