Skip to content

Commit

Permalink
Add integrity check for remote resource (#3348)
Browse files Browse the repository at this point in the history
Co-authored-by: Lukas Holländer <[email protected]>
  • Loading branch information
davel and HackbrettXXX authored Jan 21, 2022
1 parent 513a4da commit a5f8fc9
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/jspdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -3093,13 +3093,22 @@ function jsPDF(options) {
Object.prototype.toString.call(globalObject) === "[object Window]"
) {
var pdfObjectUrl =
options.pdfObjectUrl ||
"https://cdnjs.cloudflare.com/ajax/libs/pdfobject/2.1.1/pdfobject.min.js";
var integrity =
' integrity="sha512-4ze/a9/4jqu+tX9dfOqJYSvyYd5M6qum/3HpCLr+/Jqf0whc37VUbkpNGHR7/8pSnCFw47T1fmIpwBV7UySh3g==" crossorigin="anonymous"';

if (options.pdfObjectUrl) {
pdfObjectUrl = options.pdfObjectUrl;
integrity = "";
}

var htmlForNewWindow =
"<html>" +
'<style>html, body { padding: 0; margin: 0; } iframe { width: 100%; height: 100%; border: 0;} </style><body><script src="' +
pdfObjectUrl +
'"></script><script >PDFObject.embed("' +
'"' +
integrity +
'></script><script >PDFObject.embed("' +
this.output("dataurlstring") +
'", ' +
JSON.stringify(options) +
Expand Down

0 comments on commit a5f8fc9

Please sign in to comment.