aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/render.js7
-rw-r--r--lib/serve.js6
2 files changed, 8 insertions, 5 deletions
diff --git a/lib/render.js b/lib/render.js
index 680ba39..31ed74c 100644
--- a/lib/render.js
+++ b/lib/render.js
@@ -47,6 +47,10 @@ MdRenderer.prototype.image = function (ref, title, text) {
MdRenderer.prototype.link = function (ref, title, text) {
var href = this.urltransform(ref)
var name = href && /^\/(&|%26)/.test(href) && (title || text)
+ if (name) {
+ href += (/\?/.test(href) ? '&' : '?') +
+ 'filename=' + encodeURIComponent(name)
+ }
if (u.isRef(ref)) {
var myName = this.render.app.getNameSync(ref)
if (myName) title = title ? title + ' (' + myName + ')' : myName
@@ -55,8 +59,7 @@ MdRenderer.prototype.link = function (ref, title, text) {
var a = h('a', {
class: href === false ? 'bad' : undefined,
href: href !== false ? hrefToken : undefined,
- title: title || undefined,
- download: name ? encodeURIComponent(name) : undefined
+ title: title || undefined
})
// text is already html-escaped
a.innerHTML = text
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)