You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+30Lines changed: 30 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -119,6 +119,36 @@ doc.save("a4.pdf");
119
119
120
120
</details>
121
121
122
+
## Security
123
+
124
+
We strongly advise you to sanitize user input before passing it to jsPDF!
125
+
126
+
For reporting security vulnerabilities, please see [SECURITY.md](https://github.com/parallax/jsPDF/blob/master/SECURITY.md).
127
+
128
+
### Reading files from the local file system on node
129
+
130
+
When running under Node.js, jsPDF will restrict reading files from the local file system by default.
131
+
132
+
Strongly recommended: use Node's permission flags so the runtime enforces access:
* - `"./assets/*"` (any file whose resolved path starts with the resolved `./assets/` directory)
56
+
*
57
+
* Notes:
58
+
* - If Node's permission API is available (`process.permission`), it is checked first. If it denies access, reading will fail regardless of `allowFsRead`.
59
+
* - If neither `process.permission` nor `allowFsRead` is set, reading from the local file system is disabled and an error is thrown.
60
+
*
61
+
* Example:
62
+
* ```js
63
+
* const doc = jsPDF();
64
+
* doc.allowFsRead = ["./fonts/*", "./images/logo.png"]; // allow everything under ./fonts and a single file
@@ -98,10 +130,51 @@ import { jsPDF } from "../jspdf.js";
98
130
varfs=require("fs");
99
131
varpath=require("path");
100
132
101
-
url=path.resolve(url);
133
+
if(!process.permission&&!this.allowFsRead){
134
+
thrownewError(
135
+
"Trying to read a file from local file system. To enable this feature either run node with the --permission and --allow-fs-read flags or set the jsPDF.allowFsRead property."
doc.text("А ну чики брики и в дамки! А ну чики брики и в дамки! А ну чики брики и в дамки! А ну чики брики и в дамки! А ну чики брики и в дамки! А ну чики брики и в дамки! А ну чики брики и в дамки! А ну чики брики и в дамки! А ну чики брики и в дамки! ",10,10,{
191
-
align: "justify",
192
-
maxWidth: 100,
193
-
});
191
+
doc.text(
192
+
"А ну чики брики и в дамки! А ну чики брики и в дамки! А ну чики брики и в дамки! А ну чики брики и в дамки! А ну чики брики и в дамки! А ну чики брики и в дамки! А ну чики брики и в дамки! А ну чики брики и в дамки! А ну чики брики и в дамки! ",
0 commit comments