From 330ae964f3aac44f2b90786d0e3d8faf438e7eb2 Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Wed, 11 Oct 2023 11:08:25 -0600 Subject: [PATCH] Only sanitize result content on main result page The other result tabs (images/maps/videos/news) don't have text content that needs sanitizing. Fixes #1080 --- app/filter.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/filter.py b/app/filter.py index 19ce808..eef967b 100644 --- a/app/filter.py +++ b/app/filter.py @@ -161,8 +161,11 @@ class Filter: self.update_styling() self.remove_block_tabs() - for div in self.main_divs: - self.sanitize_div(div) + # self.main_divs is only populated for the main page of search results + # (i.e. not images/news/etc). + if self.main_divs: + for div in self.main_divs: + self.sanitize_div(div) for img in [_ for _ in self.soup.find_all('img') if 'src' in _.attrs]: self.update_element_src(img, 'image/png')