Skip to content

Commit c12d697

Browse files
fakelagmarcbachmann
authored andcommitted
Invert localUrlAccess to fix https://www.npmjs.com/advisories/1095
1 parent 7f054b6 commit c12d697

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

lib/pdf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function PDF (html, options) {
3636
if (!this.options.phantomPath) this.options.phantomPath = phantomjs && phantomjs.path
3737
this.options.phantomArgs = this.options.phantomArgs || []
3838

39-
if (this.options.localUrlAccess) this.options.phantomArgs.push('--local-url-access=false')
39+
if (!this.options.localUrlAccess) this.options.phantomArgs.push('--local-url-access=false')
4040
assert(this.options.phantomPath, "html-pdf: Failed to load PhantomJS module. You have to set the path to the PhantomJS binary using 'options.phantomPath'")
4141
assert(typeof this.html === 'string' && this.html.length, "html-pdf: Can't create a pdf without an html string")
4242
this.options.timeout = parseInt(this.options.timeout, 10) || 30000

test/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,29 +229,29 @@ test('load with cookies js', function (t) {
229229
})
230230
})
231231

232-
test('allows local file access with localUrlAccess=true', function (t) {
232+
test('does not allow localUrlAccess by default', function (t) {
233233
t.plan(2)
234234

235235
pdf.create(`
236236
<body>here is an iframe which receives the cookies
237237
<iframe src="file://${path.join(__dirname, 'multiple-pages.html')}" width="400" height="100"></iframe>
238238
</body>
239-
`, {localUrlAccess: true})
239+
`)
240240
.toBuffer(function (error, buffer) {
241241
t.error(error)
242242
const count = buffer.toString().match(/\/Type \/Page\n/g).length
243243
t.assert(count === 1, 'Renders a page with 1 page as the content is missing')
244244
})
245245
})
246246

247-
test('does not allow localUrlAccess by default', function (t) {
247+
test('allows local file access with localUrlAccess=true', function (t) {
248248
t.plan(2)
249249

250250
pdf.create(`
251251
<body>here is an iframe which receives the cookies
252252
<iframe src="file://${path.join(__dirname, 'multiple-pages.html')}" width="400" height="100"></iframe>
253253
</body>
254-
`)
254+
`, {localUrlAccess: true})
255255
.toBuffer(function (error, buffer) {
256256
t.error(error)
257257
const count = buffer.toString().match(/\/Type \/Page\n/g).length

0 commit comments

Comments
 (0)