Skip to content
Myr

Fix error when res.set cannot add charset to Content-Type

Before adoption: this commit came in with the history the project adopted, so no landing records it.

fixes #3303 closes #3305 closes #3307

authored by Oz Michaeli · committed by Douglas Christopher Wilson · parent 5ea2a8f · Browse files · 3 files+22 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+22 added−3 removed

  • tests:+13 added−0 removed
  • other:+9 added−3 removed

3 files+22 added−3 removed

modified:lib/response.js+8 added-3 removed
715 unmodified lines
716 ? val.map(String)717 : String(val);718719 // add charset to content-type720 if (field.toLowerCase() === 'content-type') {721 if (Array.isArray(value)) {722 throw new TypeError('Content-Type cannot be set to an Array');723 }720 if (field.toLowerCase() === 'content-type' && !charsetRegExp.test(value)) {721 var charset = mime.charsets.lookup(value.split(';')[0]);722 if (charset) value += '; charset=' + charset.toLowerCase();724 if (!charsetRegExp.test(value)) {725 var charset = mime.charsets.lookup(value.split(';')[0]);726 if (charset) value += '; charset=' + charset.toLowerCase();727 }728 }729730 this.setHeader(field, value);731 } else {
345 unmodified lines
modified:test/res.set.js+13 added
modified:History.md+1 added
1unreleased2==========34 * Fix error when `res.set` cannot add charset to `Content-Type`5 * deps: debug@2.6.36 - Fix: `DEBUG_MAX_ARRAY_LENGTH`7 * deps: finalhandler@~1.0.18 - Fix missing `</html>` in HTML document
3261 unmodified lines