mirror of
https://git.mirrors.martin98.com/https://github.com/jina-ai/reader.git
synced 2025-08-19 02:25:53 +08:00
fix: expect malformed url in iframes
This commit is contained in:
parent
92f636474d
commit
e4bc29aab8
@ -66,12 +66,20 @@ export class JSDomControl extends AsyncService {
|
|||||||
} else if (thisSnapshot?.html) {
|
} else if (thisSnapshot?.html) {
|
||||||
x.innerHTML = thisSnapshot.html;
|
x.innerHTML = thisSnapshot.html;
|
||||||
x.querySelectorAll('script, style').forEach((s) => s.remove());
|
x.querySelectorAll('script, style').forEach((s) => s.remove());
|
||||||
x.querySelectorAll('[src]').forEach((el) => {
|
if (src) {
|
||||||
el.setAttribute('src', new URL(el.getAttribute('src')!, src!).toString());
|
x.querySelectorAll('[src]').forEach((el) => {
|
||||||
});
|
const imgSrc = el.getAttribute('src')!;
|
||||||
x.querySelectorAll('[href]').forEach((el) => {
|
if (URL.canParse(imgSrc, src!)) {
|
||||||
el.setAttribute('href', new URL(el.getAttribute('href')!, src!).toString());
|
el.setAttribute('src', new URL(imgSrc, src!).toString());
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
x.querySelectorAll('[href]').forEach((el) => {
|
||||||
|
const linkHref = el.getAttribute('href')!;
|
||||||
|
if (URL.canParse(linkHref, src!)) {
|
||||||
|
el.setAttribute('href', new URL(linkHref, src!).toString());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user