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

Problems with UTF characters #205

Open
djotto opened this issue Jan 29, 2024 · 0 comments · May be fixed by #209
Open

Problems with UTF characters #205

djotto opened this issue Jan 29, 2024 · 0 comments · May be fixed by #209

Comments

@djotto
Copy link

djotto commented Jan 29, 2024

I think serve-handler isn't implementing RFC 5987 correctly.

When I attempt to serve a file with the name DALL·E 2024-01-17.png (note the bullet point) I get the following error:

$ node server.js
Server running at http://localhost:3000/
node:internal/errors:496
    ErrorCaptureStackTrace(err);
    ^

TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["Content-Disposition"]
    at storeHeader (node:_http_outgoing:580:5)
    at processHeader (node:_http_outgoing:575:3)
    at ServerResponse._storeHeader (node:_http_outgoing:451:11)
    at ServerResponse.writeHead (node:_http_server:422:8)
    at module.exports (/Users/djotto/projects/test-serve-handler/node_modules/serve-handler/src/index.js:754:11) {
  code: 'ERR_INVALID_CHAR'
}

Node.js v20.5.1

I put together a minimal demo

  • node Version: 20.5.1 (also tested on 20.11.0 FROM node:20-slim)
  • npm version: 10.2.5
  • OS: MacOs 12.7.2
  • Browser: Firefox 121.0.1
abubakriz added a commit to abubakriz/serve-handler that referenced this issue Jul 31, 2024
When a file url has certain symbols like number sign (#), it doesn't encode them, which makes the browser fail to navigate to the file, thinking it is a document section. This commit fixes that by encoding urls using the built-in encodeURIComponent function.

Fixes vercel#120, vercel#205, vercel/serve#726, and vercel/serve#774
@abubakriz abubakriz linked a pull request Jul 31, 2024 that will close this issue
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 a pull request may close this issue.

1 participant