@@ -132,14 +132,17 @@ async function actionPandoc (req, res, note) {
132132 var path = config . tmpPath + '/' + Date . now ( )
133133 content = content . replace ( / \] \( \/ / g, '](' + url + '/' )
134134
135- // TODO: check export type
136135 const { exportType } = req . query
136+ const contentType = outputFormats [ exportType ]
137137
138138 try {
139139 // TODO: timeout rejection
140+ if ( ! contentType ) {
141+ return res . sendStatus ( 400 )
142+ }
140143
141144 await pandoc . convertToFile ( content , 'markdown' , exportType , path , [
142- '--metadata' , `title=${ title } `
145+ '--metadata' , `title=${ title } ` , '--sandbox'
143146 ] )
144147
145148 var stream = fs . createReadStream ( path )
@@ -149,7 +152,7 @@ async function actionPandoc (req, res, note) {
149152 // Ideally this should strip them
150153 res . setHeader ( 'Content-disposition' , `attachment; filename="${ filename } .${ exportType } "` )
151154 res . setHeader ( 'Cache-Control' , 'private' )
152- res . setHeader ( 'Content-Type' , `${ outputFormats [ exportType ] } ; charset=UTF-8` )
155+ res . setHeader ( 'Content-Type' , `${ contentType } ; charset=UTF-8` )
153156 res . setHeader ( 'X-Robots-Tag' , 'noindex, nofollow' ) // prevent crawling
154157 stream . pipe ( res )
155158 } catch ( err ) {
0 commit comments