Skip to content

Commit

Permalink
rewrite: use if_ / fr_/ modifiers for iframes / frames again
Browse files Browse the repository at this point in the history
  • Loading branch information
ikreymer committed Oct 12, 2024
1 parent 95861e6 commit 6ef55cc
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/rewrite/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ class HTMLRewriter {
// convert object tag to iframe or img
if (type === "application/pdf") {
attr.name = "src";
attr.value = this.rewriteUrl(rewriter, attr.value);
attr.value = this.rewriteUrl(rewriter, attr.value, false, "if_");
tag.tagName = "iframe";
} else if (type === "image/svg+xml") {
attr.name = "src";
Expand All @@ -260,7 +260,7 @@ class HTMLRewriter {
const value = attr.value.replace(rule.match, rule.replace);
if (value !== attr.value) {
attr.name = "src";
attr.value = this.rewriteUrl(rewriter, value);
attr.value = this.rewriteUrl(rewriter, value, false, "if_");
tag.tagName = "iframe";
break;
}
Expand All @@ -277,6 +277,9 @@ class HTMLRewriter {
) {
attr.value = REPLAY_TOP_FRAME_NAME;
}
} else if (name === "src" && (tagName === "iframe" || tagName === "frame")) {
const mod = attrRules[name];
attr.value = this.rewriteUrl(rewriter, attr.value, false, mod);
} else if (name === "href" || name === "src") {
attr.value = this.rewriteUrl(rewriter, attr.value);
} else {
Expand Down Expand Up @@ -506,7 +509,7 @@ class HTMLRewriter {
text = decoder.decode(encodeLatin1(text));
}
const res = rewriter.rewriteUrl(text, forceAbs);
return mod ? res.replace("mp_/", mod + "/") : res;
return mod && mod !== defmod ? res.replace(defmod + "/", mod + "/") : res;
}

rewriteHTMLText(text: string) {
Expand Down

0 comments on commit 6ef55cc

Please sign in to comment.