diff options
-rw-r--r-- | lib/serve.js | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/serve.js b/lib/serve.js index a33dd71..89f7f09 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -44,6 +44,10 @@ function ctype(name) { } } +function encodeDispositionFilename(fname) { + return '"' + fname.replace(/\/g/, '\\\\').replace(/"/, '\\\"') + '"' +} + function Serve(app, req, res) { this.app = app this.req = req @@ -507,7 +511,7 @@ Serve.prototype.blob = function (id) { type = type && mime.lookup(type) if (type) self.res.setHeader('Content-Type', type) if (self.query.name) self.res.setHeader('Content-Disposition', - 'inline; filename='+encodeURIComponent(self.query.name)) + 'attachment; filename='+encodeDispositionFilename(self.query.name)) self.res.setHeader('Cache-Control', 'public, max-age=315360000') self.res.setHeader('etag', id) self.res.writeHead(200) |