@@ -132,14 +132,17 @@ async function actionPandoc (req, res, note) {
132
132
var path = config . tmpPath + '/' + Date . now ( )
133
133
content = content . replace ( / \] \( \/ / g, '](' + url + '/' )
134
134
135
- // TODO: check export type
136
135
const { exportType } = req . query
136
+ const contentType = outputFormats [ exportType ]
137
137
138
138
try {
139
139
// TODO: timeout rejection
140
+ if ( ! contentType ) {
141
+ return res . sendStatus ( 400 )
142
+ }
140
143
141
144
await pandoc . convertToFile ( content , 'markdown' , exportType , path , [
142
- '--metadata' , `title=${ title } `
145
+ '--metadata' , `title=${ title } ` , '--sandbox'
143
146
] )
144
147
145
148
var stream = fs . createReadStream ( path )
@@ -149,7 +152,7 @@ async function actionPandoc (req, res, note) {
149
152
// Ideally this should strip them
150
153
res . setHeader ( 'Content-disposition' , `attachment; filename="${ filename } .${ exportType } "` )
151
154
res . setHeader ( 'Cache-Control' , 'private' )
152
- res . setHeader ( 'Content-Type' , `${ outputFormats [ exportType ] } ; charset=UTF-8` )
155
+ res . setHeader ( 'Content-Type' , `${ contentType } ; charset=UTF-8` )
153
156
res . setHeader ( 'X-Robots-Tag' , 'noindex, nofollow' ) // prevent crawling
154
157
stream . pipe ( res )
155
158
} catch ( err ) {
0 commit comments