mirror of
https://git.mirrors.martin98.com/https://github.com/jina-ai/reader.git
synced 2025-08-18 04:35: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) {
|
||||
x.innerHTML = thisSnapshot.html;
|
||||
x.querySelectorAll('script, style').forEach((s) => s.remove());
|
||||
x.querySelectorAll('[src]').forEach((el) => {
|
||||
el.setAttribute('src', new URL(el.getAttribute('src')!, src!).toString());
|
||||
});
|
||||
x.querySelectorAll('[href]').forEach((el) => {
|
||||
el.setAttribute('href', new URL(el.getAttribute('href')!, src!).toString());
|
||||
});
|
||||
if (src) {
|
||||
x.querySelectorAll('[src]').forEach((el) => {
|
||||
const imgSrc = el.getAttribute('src')!;
|
||||
if (URL.canParse(imgSrc, src!)) {
|
||||
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