Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/note/noteActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,17 @@ async function actionPandoc (req, res, note) {
var path = config.tmpPath + '/' + Date.now()
content = content.replace(/\]\(\//g, '](' + url + '/')

// TODO: check export type
const { exportType } = req.query
const contentType = outputFormats[exportType]

try {
// TODO: timeout rejection
if (!contentType) {
return res.sendStatus(400)
}

await pandoc.convertToFile(content, 'markdown', exportType, path, [
'--metadata', `title=${title}`
'--metadata', `title=${title}`, '--sandbox'
])

var stream = fs.createReadStream(path)
Expand All @@ -149,7 +152,7 @@ async function actionPandoc (req, res, note) {
// Ideally this should strip them
res.setHeader('Content-disposition', `attachment; filename="${filename}.${exportType}"`)
res.setHeader('Cache-Control', 'private')
res.setHeader('Content-Type', `${outputFormats[exportType]}; charset=UTF-8`)
res.setHeader('Content-Type', `${contentType}; charset=UTF-8`)
res.setHeader('X-Robots-Tag', 'noindex, nofollow') // prevent crawling
stream.pipe(res)
} catch (err) {
Expand Down