Skip to content
Permalink
Browse files Browse the repository at this point in the history
block file requests
  • Loading branch information
bjrmatos committed Oct 30, 2020
1 parent ba51764 commit 6750b2f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/conversion.js
Expand Up @@ -38,6 +38,12 @@ module.exports = async ({ reporter, getBrowser, htmlUrl, strategy, timeout, req,
return
}

await page.setRequestInterception(true)

if (executionInfo.error) {
return
}

page.on('pageerror', (err) => {
pageLog('warn', `Page error: ${err.message}${err.stack ? ` , stack: ${err.stack}` : ''}`)
})
Expand All @@ -64,6 +70,19 @@ module.exports = async ({ reporter, getBrowser, htmlUrl, strategy, timeout, req,
}

pageLog('debug', `Page request: ${r.method()} (${r.resourceType()}) ${trimUrl(r.url())}${detail}`)

const isRelativeToHtmlUrl = r.url().lastIndexOf(htmlUrl, 0) === 0

if (
!isRelativeToHtmlUrl &&
// potentially dangerous request to local file
r.url().lastIndexOf('file:///', 0) === 0
) {
r.abort('accessdenied')
return
}

r.continue()
})

page.on('requestfinished', (r) => {
Expand Down

0 comments on commit 6750b2f

Please sign in to comment.