diff options
author | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2020-02-27 13:33:23 -0500 |
---|---|---|
committer | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2020-02-27 13:33:23 -0500 |
commit | b5cec405f40f6e5b5d444613f5f2f6ebc42507aa (patch) | |
tree | b2c16ac4a23a2d62b4c7b538a2016e002a4dc8c8 /lib/serve.js | |
parent | e1a9df691c91e6793204528df331894efe952484 (diff) | |
download | patchfoo-b5cec405f40f6e5b5d444613f5f2f6ebc42507aa.tar.gz patchfoo-b5cec405f40f6e5b5d444613f5f2f6ebc42507aa.zip |
Fix blob filename handling
Make links to HTML blobs not prompt to download
Diffstat (limited to 'lib/serve.js')
-rw-r--r-- | lib/serve.js | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/serve.js b/lib/serve.js index 96f8313..556e70f 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -48,7 +48,7 @@ function ctype(name) { } function encodeDispositionFilename(fname) { - fname = fname.replace(/\/g/, '\\\\').replace(/"/, '\\\"') + fname = String(fname).replace(/\/g/, '\\\\').replace(/"/, '\\\"') return '"' + encodeURIComponent(fname) + '"' } @@ -1570,7 +1570,7 @@ Serve.prototype.blob = function (id, path) { if (typeof size === 'number' && !key) self.res.setHeader('Content-Length', size) if (self.query.filename) self.res.setHeader('Content-Disposition', - 'inline; filename='+encodeDispositionFilename(self.query.name)) + 'inline; filename='+encodeDispositionFilename(self.query.filename)) if (self.query.gzip) self.res.setHeader('Content-Encoding', 'gzip') if (self.query.contentType) @@ -1656,7 +1656,7 @@ Serve.prototype.image = function (path) { if (type) self.res.setHeader('Content-Type', type) self.res.setHeader('Content-Length', data.length) if (self.query.filename) self.res.setHeader('Content-Disposition', - 'inline; filename='+encodeDispositionFilename(self.query.name)) + 'inline; filename='+encodeDispositionFilename(self.query.filename)) if (self.query.gzip) self.res.setHeader('Content-Encoding', 'gzip') if (self.query.contentType) |