Skip to content

Commit

Permalink
rewrite <object> with image/svg+xml to <img> tag
Browse files Browse the repository at this point in the history
bump to 3.7.5
  • Loading branch information
ikreymer committed Jun 5, 2024
1 parent 0869a95 commit 1135c80
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@webrecorder/wombat",
"version": "3.7.4",
"version": "3.7.5",
"main": "index.js",
"license": "AGPL-3.0-or-later",
"author": "Ilya Kreymer, Webrecorder Software",
Expand Down
20 changes: 15 additions & 5 deletions src/wombat.js
Original file line number Diff line number Diff line change
Expand Up @@ -2014,7 +2014,7 @@ Wombat.prototype.rewriteAttr = function(elem, name, absUrlOnly) {
return changed;
}

var value = this.wb_getAttribute.call(elem, name);
var value = this.wb_getAttribute.call(this.proxyToObj(elem), name);

if (!value || this.startsWith(value, 'javascript:')) return changed;

Expand Down Expand Up @@ -2237,18 +2237,26 @@ Wombat.prototype.rewriteElem = function(elem) {
}
break;
case 'OBJECT':
if (this.wb_info.isSW && elem.parentElement && elem.getAttribute('type') === 'application/pdf') {
var iframe = this.$wbwindow.document.createElement('IFRAME');
if (this.wb_info.isSW && elem.parentElement) {
var altElemName;

if (elem.getAttribute('type') === 'application/pdf') {
altElemName = 'IFRAME';
} else if (elem.getAttribute('type') === 'image/svg+xml') {
altElemName = 'IMG';
}

var newElem = this.$wbwindow.document.createElement(altElemName);
for (var i = 0; i < elem.attributes.length; i++) {
var attr = elem.attributes[i];
var name = attr.name;
if (name === 'data') {
name = 'src';
}
this.wb_setAttribute.call(iframe, name, attr.value);
this.wb_setAttribute.call(newElem, name, attr.value);
}

elem.parentElement.replaceChild(iframe, elem);
elem.parentElement.replaceChild(newElem, elem);
changed = true;
break;
}
Expand Down Expand Up @@ -4527,6 +4535,8 @@ Wombat.prototype.initHTTPOverrides = function() {
this.__WB_xhr_headers = new Headers();
};

this.$wbwindow.XMLHttpRequest.prototype.setAttributionReporting = function() {};

this.$wbwindow.XMLHttpRequest.prototype.setRequestHeader = function(name, value) {
this.__WB_xhr_headers.set(name, value);
};
Expand Down

0 comments on commit 1135c80

Please sign in to comment.