Merge pull request #13421 from calixteman/no_remote_image

XFA - Don't display images with a href
This commit is contained in:
Tim van der Meij 2021-05-22 16:06:33 +02:00 committed by GitHub
commit 3538ef017f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2248,24 +2248,25 @@ class Image extends StringObject {
}
[$toHTML]() {
const html = {
name: "img",
attributes: {
class: "xfaImage",
style: {},
},
};
if (this.href) {
html.attributes.src = new URL(this.href).href;
return html;
if (this.href || !this[$content]) {
// TODO: href can be a Name refering to an internal stream
// containing a picture.
// In general, we don't get remote data and use what we have
// in the pdf itself, so no picture for non null href.
return null;
}
if (this.transferEncoding === "base64") {
const buffer = stringToBytes(atob(this[$content]));
const blob = new Blob([buffer], { type: this.contentType });
html.attributes.src = URL.createObjectURL(blob);
return html;
return {
name: "img",
attributes: {
class: "xfaImage",
style: {},
src: URL.createObjectURL(blob),
},
};
}
return null;