Skip to content

Commit d20ac0b

Browse files
authored
new method setUrlAccessPolicy() (#2920)
* added `setUrlAccessPolicy()` for defining a custom access policy for external URLs before download * Add warning for undefined URL access policy when running on server or CLI * fix examples * fix * fix server detection * Update CHANGELOG.md
1 parent f3c202a commit d20ac0b

35 files changed

+245
-21
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
## Unreleased
44

5+
- Added `setUrlAccessPolicy()` for defining a custom access policy for external URLs before download
6+
(addresses a potential server vulnerability **CVE-2026-26801**)
7+
8+
Example:
9+
```js
10+
pdfmake.setUrlAccessPolicy((url) => {
11+
// check allowed domain
12+
return url.startsWith("https://example.com/");
13+
});
14+
For details see [documentation](https://pdfmake.github.io/docs/0.3/getting-started/server-side/methods/#url-access-policy)
515
- Added validation for image height and width values
616

717
## 0.3.5 - 2026-02-22

examples/absolute.js

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/attachments.js

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/background.js

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/basics.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ pdfmake.addFonts({
1616
});
1717
*/
1818

19+
pdfmake.setUrlAccessPolicy((url) => {
20+
// this can be used to restrict allowed domains
21+
return url.startsWith('https://');;
22+
});
23+
24+
1925
var docDefinition = {
2026
content: [
2127
'First paragraph',

examples/columns_simple.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ var pdfmake = require('../js/index'); // only during development, otherwise use
44
var Roboto = require('../fonts/Roboto');
55
pdfmake.addFonts(Roboto);
66

7+
pdfmake.setUrlAccessPolicy((url) => {
8+
// this can be used to restrict allowed domains
9+
return url.startsWith('https://');;
10+
});
11+
712

813
var docDefinition = {
914
content: [

examples/images.js

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/links.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ var pdfmake = require('../js/index'); // only during development, otherwise use
44
var Roboto = require('../fonts/Roboto');
55
pdfmake.addFonts(Roboto);
66

7+
pdfmake.setUrlAccessPolicy((url) => {
8+
// this can be used to restrict allowed domains
9+
return url.startsWith('https://');;
10+
});
11+
12+
713
var docDefinition = {
814
content: [
915
{

examples/lists.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ var pdfmake = require('../js/index'); // only during development, otherwise use
44
var Roboto = require('../fonts/Roboto');
55
pdfmake.addFonts(Roboto);
66

7+
pdfmake.setUrlAccessPolicy((url) => {
8+
// this can be used to restrict allowed domains
9+
return url.startsWith('https://');;
10+
});
11+
712

813
var docDefinition = {
914
content: [

examples/margins.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ var pdfmake = require('../js/index'); // only during development, otherwise use
44
var Roboto = require('../fonts/Roboto');
55
pdfmake.addFonts(Roboto);
66

7+
pdfmake.setUrlAccessPolicy((url) => {
8+
// this can be used to restrict allowed domains
9+
return url.startsWith('https://');;
10+
});
11+
712

813
var docDefinition = {
914
content: [

0 commit comments

Comments
 (0)