moz_readability/mod.rs: fix laziness check in fix_lazy_images

fix_lazy_images checks whether an img node is lazily loaded. An img is
considered lazily loaded if it does not have an src/srcset attribute, or
if it's class contains the 'lazy' string. If an img is considered lazy,
fix_lazy_images will make attempts to replace it's src.

However, if an img was missing the class attribute, it was incorrectly
assumed to be lazy and had it's src replaced.

Fixes hipstermojo/paperoni#13
This commit is contained in:
KOVACS Tamas 2021-05-10 01:33:12 +02:00
parent d50f08b875
commit 7649f6aa18

View file

@ -1248,8 +1248,7 @@ impl Readability {
let srcset = node_attr.get("srcset");
let class = node_attr.get("class");
if (src.is_some() || srcset.is_some())
&& class.is_some()
&& !class.unwrap().contains("lazy")
&& class.and_then(|classname| classname.find("lazy")).is_none()
{
continue;
}