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

Express adding charset to Content-Type #2654

Closed
julien51 opened this issue May 19, 2015 · 3 comments
Closed

Express adding charset to Content-Type #2654

julien51 opened this issue May 19, 2015 · 3 comments
Assignees

Comments

@julien51
Copy link

We found that by default Express adds the utf-8 charset by default to the Content-Type string. But does it always make sense? The W3C spec says:

Documents transmitted with HTTP that are of type text, such as text/html, text/plain, etc., can send a charset parameter in the HTTP header to specify the character encoding of the document.

However, sometimes people use Content-Typewhich are not text based, like application/... and in their cases, it probably not blindly add charset:utf-8.

@dougwilson
Copy link
Contributor

We do this to protect you from certain attacks. If you don't want it added, then either don't use res.send or give res.send a Buffer instead of a string (since Buffer is not text and a string is text).

@dougwilson dougwilson self-assigned this May 19, 2015
@dougwilson dougwilson changed the title Express 4.X adds charset to Content-Type Express adding charset to Content-Type May 19, 2015
@juliankrispel
Copy link

@dougwilson Maybe documenting that somewhere would be a good idea?

@dougwilson
Copy link
Contributor

@juliankrispel I didn't realize it wasn't, I'm sorry! Please open an issue at https://github.com/strongloop/expressjs.com (or even a PR), to get this documented :)! We implemented it because Express was seriously exploited previously, enough to get us not doing this CVE-2014-6393.

@expressjs expressjs locked and limited conversation to collaborators Jun 22, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants