Fix crash with unsafe strings

This commit is contained in:
Michel Roux 2020-04-07 10:51:00 +02:00
parent fc019007fa
commit cd896f4dad

View File

@ -229,16 +229,18 @@ class Nyaa(Connector):
url = urls[0] url = urls[0]
has_comment = False 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 continue
valid_trs = valid_trs + 1 valid_trs = valid_trs + 1
href = '%s%s' % (self.base_url, url['href']) href = '%s%s' % (self.base_url, url['href'])
self.data.append({ self.data.append({
'lang': self.get_lang(url.string), 'lang': self.get_lang(url_safe),
'href': href, 'href': href,
'name': url.string, 'name': url_safe,
'comment': str(urls[0]).replace('/view/', 'comment': str(urls[0]).replace('/view/',
'%s%s' % (self.base_url, '/view/')) if has_comment else '', '%s%s' % (self.base_url, '/view/')) if has_comment else '',
'link': tds[2].decode_contents().replace('/download/', 'link': tds[2].decode_contents().replace('/download/',
@ -293,7 +295,7 @@ class Pantsu(Connector):
if check_downloads or check_seeds: if check_downloads or check_seeds:
url = tds[1].a 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): if any(word.lower() in url_safe.lower() for word in BLACKLIST_WORDS):
continue continue
@ -378,16 +380,17 @@ class YggTorrent(Connector):
if check_downloads or check_seeds: if check_downloads or check_seeds:
url = tds[1].a 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 continue
valid_trs = valid_trs + 1 valid_trs = valid_trs + 1
self.data.append({ self.data.append({
'lang': self.get_lang(url.string), 'lang': self.get_lang(url_safe),
'href': url['href'], 'href': url['href'],
'name': url.string, 'name': url_safe,
'comment': '<a href="%s#comm" target="_blank"><i class="fa fa-comments-o"></i>%s</a>' % 'comment': '<a href="%s#comm" target="_blank"><i class="fa fa-comments-o"></i>%s</a>' %
(url['href'], tds[3].decode_contents()), (url['href'], tds[3].decode_contents()),
'link': '<a href="%s/engine/download_torrent?id=%s">' 'link': '<a href="%s/engine/download_torrent?id=%s">'