Skip to content
Myr

Fix res.attachment Unicode filenames in Safari

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

closes #2188

authored by 刘星 · committed by Douglas Christopher Wilson · parent 6aba1b4 · Browse files · 5 files+6 added−2 removed
This commit

State

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

Diff stats

5 files+6 added−2 removed

  • tests:+1 added−1 removed
  • other:+5 added−1 removed

5 files+6 added−2 removed

added:examples/downloads/files/CCTV大赛上海分赛区.txt+2 added
1Only for test.2The file name is faked.
modified:examples/downloads/app.js+1 added
modified:lib/utils.js+1 added-1 removed
162 unmodified lines
163 if (filename) {164 filename = basename(filename);165 // if filename contains non-ascii characters, add a utf-8 version ala RFC 5987166 ret = /[^\040-\176]/.test(filename)167 ? 'attachment; filename=' + encodeURI(filename) + '; filename*=UTF-8\'\'' + encodeURI(filename)167 ? 'attachment; filename="' + encodeURI(filename) + '"; filename*=UTF-8\'\'' + encodeURI(filename)168 : 'attachment; filename="' + filename + '"';169 }170171 return ret;
121 unmodified lines
modified:test/res.attachment.js+1 added-1 removed
modified:History.md+1 added
1unreleased2==========34 * fix `res.attachment` Unicode filenames in Safari5 * fix "trim prefix" debug message in `express:router`6 * deps: accepts@~1.0.57 * deps: buffer-crc32@0.2.38
1637 unmodified lines