Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add integrity check for remote resource
Don't blindly trust free CDNs.
  • Loading branch information
davel committed Dec 28, 2021
commit 9e4be53cfeceb647d92080f2fc37ea07758ffd3a
13 changes: 11 additions & 2 deletions src/jspdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -3090,13 +3090,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="sha384-KORHK+C7FM+M/ymOjflwOQOMla5IGEvf39mP/riZhRegDgSjIsBoSt4q+eNExcCn" 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