From cd896f4dad310154a6a7b3a6127036f22189a05f Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Tue, 7 Apr 2020 10:51:00 +0200 Subject: [PATCH] Fix crash with unsafe strings --- connectors.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/connectors.py b/connectors.py index 0a9265a..7bcce30 100644 --- a/connectors.py +++ b/connectors.py @@ -229,16 +229,18 @@ class Nyaa(Connector): url = urls[0] has_comment = False - if any(word.lower() in url.string.lower() for word in BLACKLIST_WORDS): + url_safe = url.get_text() + + if any(word.lower() in url_safe.lower() for word in BLACKLIST_WORDS): continue valid_trs = valid_trs + 1 href = '%s%s' % (self.base_url, url['href']) self.data.append({ - 'lang': self.get_lang(url.string), + 'lang': self.get_lang(url_safe), 'href': href, - 'name': url.string, + 'name': url_safe, 'comment': str(urls[0]).replace('/view/', '%s%s' % (self.base_url, '/view/')) if has_comment else '', 'link': tds[2].decode_contents().replace('/download/', @@ -293,7 +295,7 @@ class Pantsu(Connector): if check_downloads or check_seeds: url = tds[1].a - url_safe = ''.join(url.strings) + url_safe = url.get_text() if any(word.lower() in url_safe.lower() for word in BLACKLIST_WORDS): continue @@ -378,16 +380,17 @@ class YggTorrent(Connector): if check_downloads or check_seeds: url = tds[1].a + url_safe = url.get_text() - if any(word.lower() in url.string.lower() for word in BLACKLIST_WORDS): + if any(word.lower() in url_safe.lower() for word in BLACKLIST_WORDS): continue valid_trs = valid_trs + 1 self.data.append({ - 'lang': self.get_lang(url.string), + 'lang': self.get_lang(url_safe), 'href': url['href'], - 'name': url.string, + 'name': url_safe, 'comment': '%s' % (url['href'], tds[3].decode_contents()), 'link': ''