Skip to content

strip a windows drive or stream prefix in sanitize_filename - #2651

Merged
yhirose merged 1 commit into
yhirose:masterfrom
metsw24-max:sanitize-filename-drive-prefix
Oct 27, 2026
Merged

yhirose merged 1 commit into
yhirose:masterfrom
metsw24-max:sanitize-filename-drive-prefix

Conversation

@metsw24-max

Copy link
Copy Markdown
Contributor

Windows drive prefix survives sanitize_filename
On Windows a ':' ends a drive prefix or starts an NTFS stream name, but sanitize_filename only cuts at / and \, so an uploaded filename of C:.. or C:evil.dll comes back unchanged: joined with std::filesystem::path it replaces the upload directory (a different root name wins in operator/), and joined as a string a:b writes a hidden stream of a. I've made ':' a separator on Windows only, in line with is_valid_path after #2643; the new test pins both platforms, though its Windows branch only runs in the Windows CI job.

On Windows a ':' ends a drive prefix or names an NTFS stream, so a multipart
filename such as C:.. or C:evil.dll passed sanitize_filename unchanged. Treat
':' as a separator there; elsewhere it stays an ordinary file name character.
@yhirose
yhirose merged commit 578e481 into yhirose:master Oct 27, 2026
27 of 28 checks passed
@yhirose

yhirose commented Oct 27, 2026

Copy link
Copy Markdown
Owner

Thanks!

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