Skip to content

Commit 7fc0c39

Browse files
committed
Fix regular expressions used in meta
The meta feature did not work with regular expressions. This should now be fixed.
1 parent 228752a commit 7fc0c39

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

qubes-keepass.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,18 @@ def contains_qube(qube_list: list, qube: str) -> bool:
7777

7878
for entry in qube_list:
7979

80-
if type(entry) == str and entry == qube:
81-
return True
80+
if type(entry) == str:
8281

83-
elif entry.fullmatch(qube):
84-
return True
82+
if entry == qube:
83+
return True
84+
85+
elif type(entry) == re.Pattern:
86+
87+
if entry.fullmatch(qube):
88+
return True
89+
90+
else:
91+
raise InternalError(f'Unsupported list entry type: {type(entry)}')
8592

8693
return False
8794

@@ -98,6 +105,12 @@ class MissingConfigException(Exception):
98105
'''
99106

100107

108+
class InternalError(Exception):
109+
'''
110+
Custom exception class.
111+
'''
112+
113+
101114
class UuidCache:
102115
'''
103116
The UuidCache class is responsible for tracking which credentials were used most
@@ -490,6 +503,7 @@ def __init__(self, item: Secret.Item, service: Secret.Service) -> None:
490503

491504
if Config.getboolean('regex') and self.qubes is not None:
492505
self.qubes = list(map(re.compile, self.qubes))
506+
self.meta = list(map(re.compile, self.meta))
493507

494508
def __str__(self) -> str:
495509
'''
@@ -883,6 +897,11 @@ def main() -> None:
883897
print('[-] Error message: ' + str(e))
884898
return
885899

900+
except InternalError as e:
901+
print('[-] Internal Error.')
902+
print('[-] Error message: ' + str(e))
903+
return
904+
886905
except RofiAbortedException:
887906
print('[+] Aborted.')
888907
return

0 commit comments

Comments
 (0)