Make CodeQL happy

None of these are actual issues, as is usual for CodeQL
This commit is contained in:
Kovid Goyal 2025-09-15 12:42:35 +05:30
parent 85ece7d311
commit 1f69ab8701
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 10 additions and 3 deletions

View File

@ -124,7 +124,7 @@ def parse_index(raw=None): # {{{
return category
raise ValueError('Could not find category for offset: ' + str(offset))
for match in re.finditer(r'''(?is)<li.+?<a\s+href=['"](https://www.mobileread.com/forums/showthread.php\?[pt]=\d+).+?>(.+?)<(.+?)</li>''', raw):
for match in re.finditer(r'''(?is)<li.+?<a\s+href=['"](https://www\.mobileread\.com/forums/showthread\.php\?[pt]=\d+).+?>(.+?)<(.+?)</li>''', raw):
name, url, rest = u(match.group(2)), u(match.group(1)), match.group(3)
category = category_at(match.start(2))
deprecated = category == deprecated_category

View File

@ -398,6 +398,7 @@ class GoogleBooks(Source):
timeout=30
):
from calibre.utils.filenames import ascii_text
from polyglot.urllib import urlparse
isbn = check_isbn(identifiers.get('isbn', None))
q = []
strip_punc_pat = regex.compile(r'[\p{C}|\p{M}|\p{P}|\p{S}|\p{Z}]+', regex.UNICODE)
@ -440,7 +441,13 @@ class GoogleBooks(Source):
pat = re.compile(r'id=([^&]+)')
for q in se.google_parse_results(root, r[0], log=log, ignore_uncached=False):
m = pat.search(q.url)
if m is None or not q.url.startswith('https://books.google'):
if m is None or not q.url:
continue
try:
purl = urlparse(q.url)
except Exception:
continue
if not purl.hostname.startswith('https://books.google'):
continue
google_ids.append(m.group(1))

View File

@ -336,7 +336,7 @@ def google_parse_results(root, raw, log=prints, ignore_uncached=True):
purl = urlparse(url)
except Exception:
continue
if 'google.com' in purl.netloc:
if purl.hostname.endswith('google.com'):
continue
try:
title = tostring(next(a.iterchildren('span')))