Skip to content

Commit 0727c6e

Browse files
authored
Check noscript contains a single image before making a copy (#892)
This avoids a bit of unnecessary work if the noscript isn't relevant to the situation
1 parent b59a6bb commit 0727c6e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Readability.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1892,16 +1892,16 @@ Readability.prototype = {
18921892
var noscripts = Array.from(doc.getElementsByTagName("noscript"));
18931893
this._forEachNode(noscripts, function (noscript) {
18941894
// Parse content of noscript and make sure it only contains image
1895+
if (!this._isSingleImage(noscript)) {
1896+
return;
1897+
}
18951898
var tmp = doc.createElement("div");
18961899
// We're running in the document context, and using unmodified
18971900
// document contents, so doing this should be safe.
18981901
// (Also we heavily discourage people from allowing script to
18991902
// run at all in this document...)
19001903
// eslint-disable-next-line no-unsanitized/property
19011904
tmp.innerHTML = noscript.innerHTML;
1902-
if (!this._isSingleImage(tmp)) {
1903-
return;
1904-
}
19051905

19061906
// If noscript has previous sibling and it only contains image,
19071907
// replace it with noscript content. However we also keep old

0 commit comments

Comments
 (0)