Use the FULLCASE flag for db and filename searches

This commit is contained in:
Kovid Goyal 2020-08-29 10:23:20 +05:30
parent 9f1e1e5a18
commit cb161b4f76
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 3 additions and 3 deletions

View File

@ -72,7 +72,7 @@ def _match(query, value, matchkind, use_primary_find_in_search=True, case_sensit
elif query == t:
return True
elif matchkind == REGEXP_MATCH:
flags = regex.UNICODE | regex.VERSION1 | (0 if case_sensitive else regex.IGNORECASE)
flags = regex.UNICODE | regex.VERSION1 | regex.FULLCASE | (0 if case_sensitive else regex.IGNORECASE)
if regex.search(query, t, flags) is not None:
return True
elif matchkind == CONTAINS_MATCH:

View File

@ -106,7 +106,7 @@ def _get_metadata(stream, stream_type, use_libprs_metadata,
name = os.path.basename(getattr(stream, 'name', ''))
# The fallback pattern matches the default filename format produced by calibre
base = metadata_from_filename(name, pat=pattern, fallback_pat=regex.compile(
r'^(?P<title>.+) - (?P<author>[^-]+)$', flags=regex.UNICODE | regex.VERSION1))
r'^(?P<title>.+) - (?P<author>[^-]+)$', flags=regex.UNICODE | regex.VERSION1 | regex.FULLCASE))
if not base.authors:
base.authors = [_('Unknown')]
if not base.title:
@ -133,7 +133,7 @@ def metadata_from_filename(name, pat=None, fallback_pat=None):
name = name.rpartition('.')[0]
mi = MetaInformation(None, None)
if pat is None:
pat = regex.compile(prefs.get('filename_pattern'), flags=regex.UNICODE | regex.VERSION1)
pat = regex.compile(prefs.get('filename_pattern'), flags=regex.UNICODE | regex.VERSION1 | regex.FULLCASE)
name = name.replace('_', ' ')
match = pat.search(name)
if match is None and fallback_pat is not None: