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

Should \u202f get sanitized? #78

Closed
rodrigoborgesdeoliveira opened this issue Feb 10, 2023 · 2 comments
Closed

Should \u202f get sanitized? #78

rodrigoborgesdeoliveira opened this issue Feb 10, 2023 · 2 comments

Comments

@rodrigoborgesdeoliveira

When streaming a filename with a \u202f character using express.js, it throws an error when setting the Content-Disposition header:

// throws ERR_INVALID_CHAR
res.setHeader(
    'Content-Disposition',
    'attachment; filename="example\u202f.txt"',
);

After sanitizing a string with the \u202f character, it is still present in the string. Should it get sanitized by sanitize-filename or is that expected?

@parshap
Copy link
Owner

parshap commented Feb 10, 2023

It looks like node's response.setHeader is what is rejecting the string. Since this module is about sanitizing strings to be safe as filenames in filesystems, I'm not sure sanitizing \u202f or other control characters response.setHeader rejects is appropriate. It looks like this package might help make sure your filename is safe for header use: https://github.com/jshttp/content-disposition

@rodrigoborgesdeoliveira
Copy link
Author

Got it. Thanks, @parshap.

@rodrigoborgesdeoliveira rodrigoborgesdeoliveira closed this as not planned Won't fix, can't repro, duplicate, stale Feb 10, 2023
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

No branches or pull requests

2 participants