Skip to content

Commit

Permalink
fix: only allow string type exportType paramter
Browse files Browse the repository at this point in the history
fixes #1846

Signed-off-by: Yukai Huang <yukaihuangtw@gmail.com>
  • Loading branch information
Yukaii committed Jan 4, 2024
1 parent 0f4b988 commit cd52cb7
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/note/noteActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,17 @@ async function actionPandoc (req, res, note) {
content = content.replace(/\]\(\//g, '](' + url + '/')

const { exportType } = req.query
if (typeof exportType !== 'string') {
return res.sendStatus(400)
}

const contentType = outputFormats[exportType]
if (!contentType) {
return res.sendStatus(400)
}

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

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

0 comments on commit cd52cb7

Please sign in to comment.