mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
catch invalid regex in field search
This commit is contained in:
parent
6559020d1f
commit
78a209edec
1 changed files with 6 additions and 2 deletions
|
@ -5,6 +5,7 @@
|
|||
import re
|
||||
from anki.utils import ids2str, splitFields, joinFields, stripHTML, intTime
|
||||
from anki.consts import *
|
||||
import sre_constants
|
||||
|
||||
# Find
|
||||
##########################################################################
|
||||
|
@ -417,8 +418,11 @@ where mid in %s and flds like ? escape '\\'""" % (
|
|||
flds = splitFields(flds)
|
||||
ord = mods[str(mid)][1]
|
||||
strg = flds[ord]
|
||||
if re.search("(?i)^"+regex+"$", strg):
|
||||
nids.append(id)
|
||||
try:
|
||||
if re.search("(?i)^"+regex+"$", strg):
|
||||
nids.append(id)
|
||||
except sre_constants.error:
|
||||
return
|
||||
if not nids:
|
||||
return
|
||||
return "n.id in %s" % ids2str(nids)
|
||||
|
|
Loading…
Reference in a new issue