mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-14 15:00:01 -04:00
fix: handle events in html rewriter
This commit is contained in:
parent
9bd880ac8a
commit
565b6cee68
1 changed files with 13 additions and 2 deletions
|
@ -198,7 +198,7 @@ function traverseParsedHtml(
|
||||||
meta.base = new URL(node.attribs.href, meta.origin);
|
meta.base = new URL(node.attribs.href, meta.origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node.attribs)
|
if (node.attribs) {
|
||||||
for (const rule of htmlRules) {
|
for (const rule of htmlRules) {
|
||||||
for (const attr in rule) {
|
for (const attr in rule) {
|
||||||
const sel = rule[attr];
|
const sel = rule[attr];
|
||||||
|
@ -218,6 +218,17 @@ function traverseParsedHtml(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (const [attr, value] of Object.entries(node.attribs)) {
|
||||||
|
if (attr.startsWith("on")) {
|
||||||
|
node.attribs[`data-scramjet-${attr}`] = attr;
|
||||||
|
node.attribs[attr] = rewriteJs(
|
||||||
|
value as string,
|
||||||
|
`(inline ${attr} on element)`,
|
||||||
|
meta
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (node.name === "style" && node.children[0] !== undefined)
|
if (node.name === "style" && node.children[0] !== undefined)
|
||||||
node.children[0].data = rewriteCss(node.children[0].data, meta);
|
node.children[0].data = rewriteCss(node.children[0].data, meta);
|
||||||
|
@ -239,7 +250,7 @@ function traverseParsedHtml(
|
||||||
node.children[0].data = rewriteJs(js, "(inline script element)", meta);
|
node.children[0].data = rewriteJs(js, "(inline script element)", meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node.name === "meta" && node.attribs["http-equiv"] != undefined) {
|
if (node.name === "meta" && node.attribs["http-equiv"] !== undefined) {
|
||||||
if (
|
if (
|
||||||
node.attribs["http-equiv"].toLowerCase() === "content-security-policy"
|
node.attribs["http-equiv"].toLowerCase() === "content-security-policy"
|
||||||
) {
|
) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue