Skip to content
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

Why does secure_filename() remove a leading underscore? #1398

Closed
Siecje opened this issue Nov 16, 2018 · 1 comment
Closed

Why does secure_filename() remove a leading underscore? #1398

Siecje opened this issue Nov 16, 2018 · 1 comment

Comments

@Siecje
Copy link

Siecje commented Nov 16, 2018

Why does werkzeug.utils.secure_filename() remove a leading underscore? Is it safe to add it back after?

>>> from werkzeug import utils
>>> utils.secure_filename('_why.py')
'why.py'

assert utils.secure_filename('__filename__') == 'filename'

@davidism
Copy link
Member

Seems to be for normalization purposes. You can do whatever you want to the filenames, but evaluating their security is up to you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants