Skip to content

Commit a5f8fc9

Browse files
davelHackbrettXXX
andauthored
Add integrity check for remote resource (#3348)
Co-authored-by: Lukas Holländer <[email protected]>
1 parent 513a4da commit a5f8fc9

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/jspdf.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3093,13 +3093,22 @@ function jsPDF(options) {
30933093
Object.prototype.toString.call(globalObject) === "[object Window]"
30943094
) {
30953095
var pdfObjectUrl =
3096-
options.pdfObjectUrl ||
30973096
"https://cdnjs.cloudflare.com/ajax/libs/pdfobject/2.1.1/pdfobject.min.js";
3097+
var integrity =
3098+
' integrity="sha512-4ze/a9/4jqu+tX9dfOqJYSvyYd5M6qum/3HpCLr+/Jqf0whc37VUbkpNGHR7/8pSnCFw47T1fmIpwBV7UySh3g==" crossorigin="anonymous"';
3099+
3100+
if (options.pdfObjectUrl) {
3101+
pdfObjectUrl = options.pdfObjectUrl;
3102+
integrity = "";
3103+
}
3104+
30983105
var htmlForNewWindow =
30993106
"<html>" +
31003107
'<style>html, body { padding: 0; margin: 0; } iframe { width: 100%; height: 100%; border: 0;} </style><body><script src="' +
31013108
pdfObjectUrl +
3102-
'"></script><script >PDFObject.embed("' +
3109+
'"' +
3110+
integrity +
3111+
'></script><script >PDFObject.embed("' +
31033112
this.output("dataurlstring") +
31043113
'", ' +
31053114
JSON.stringify(options) +

0 commit comments

Comments
 (0)