mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 01:06:35 -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
|
import re
|
||||||
from anki.utils import ids2str, splitFields, joinFields, stripHTML, intTime
|
from anki.utils import ids2str, splitFields, joinFields, stripHTML, intTime
|
||||||
from anki.consts import *
|
from anki.consts import *
|
||||||
|
import sre_constants
|
||||||
|
|
||||||
# Find
|
# Find
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
@ -417,8 +418,11 @@ where mid in %s and flds like ? escape '\\'""" % (
|
||||||
flds = splitFields(flds)
|
flds = splitFields(flds)
|
||||||
ord = mods[str(mid)][1]
|
ord = mods[str(mid)][1]
|
||||||
strg = flds[ord]
|
strg = flds[ord]
|
||||||
|
try:
|
||||||
if re.search("(?i)^"+regex+"$", strg):
|
if re.search("(?i)^"+regex+"$", strg):
|
||||||
nids.append(id)
|
nids.append(id)
|
||||||
|
except sre_constants.error:
|
||||||
|
return
|
||||||
if not nids:
|
if not nids:
|
||||||
return
|
return
|
||||||
return "n.id in %s" % ids2str(nids)
|
return "n.id in %s" % ids2str(nids)
|
||||||
|
|
Loading…
Reference in a new issue