Skip to content

Comments

ServeDir to call fallback for invalid filenames (fixes #573)#586

Merged
jplatte merged 10 commits intotower-rs:mainfrom
aryaveersr:main
Jun 20, 2025
Merged

ServeDir to call fallback for invalid filenames (fixes #573)#586
jplatte merged 10 commits intotower-rs:mainfrom
aryaveersr:main

Conversation

@aryaveersr
Copy link
Contributor

Motivation

( See #573 )

ServeDir currently returns ISE for any request involving invalid filenames (eg: /path|name/). This fixes it so that it instead forwards the request to the fallback (as it should).

Solution

This uses a rather ugly solution of manually checking Raw OS error codes for windows. If we ever upgrade MSRV to 1.87 or beyond, we should instead use io::ErrorKind::InvalidFilename (stabilized in 1.87). I've also put a comment with FIXME regarding this.

@aryaveersr aryaveersr changed the title ServeDir calls fallback for invalid filenames (fixes #573) ServeDir to call fallback for invalid filenames (fixes #573) Jun 13, 2025
@aryaveersr aryaveersr marked this pull request as draft June 13, 2025 19:42
@aryaveersr aryaveersr marked this pull request as ready for review June 13, 2025 19:57
Copy link
Member

@jplatte jplatte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, especially for including tests!

@aryaveersr aryaveersr requested a review from jplatte June 20, 2025 12:27
Copy link
Member

@jplatte jplatte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@jplatte
Copy link
Member

jplatte commented Jun 20, 2025

One last thing, could you add a changelog entry please?

@aryaveersr aryaveersr requested a review from jplatte June 20, 2025 12:36
@jplatte jplatte enabled auto-merge (squash) June 20, 2025 12:38
@jplatte jplatte merged commit cf3046f into tower-rs:main Jun 20, 2025
11 checks passed
@seanmonstar seanmonstar mentioned this pull request Nov 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants