String: Display regex error on invalid group reference (#1537)

This commit is contained in:
Tasos Sahanidis 2023-06-04 22:51:27 +03:00 committed by GitHub
parent 416a05e326
commit 6021f0e6d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -218,20 +218,21 @@ class String(callbacks.Plugin):
s/regexp/replacement/flags, returns the result of applying such a s/regexp/replacement/flags, returns the result of applying such a
regexp to <text>. regexp to <text>.
""" """
if f('') and len(f(' ')) > len(f(''))+1: # Matches the empty string. try:
s = _('You probably don\'t want to match the empty string.') if f('') and len(f(' ')) > len(f(''))+1: # Matches the empty string.
irc.error(s) s = _('You probably don\'t want to match the empty string.')
else: irc.error(s)
t = self.registryValue('re.timeout') else:
try: t = self.registryValue('re.timeout')
v = process(f, text, timeout=t, pn=self.name(), cn='re') try:
if isinstance(v, list): v = process(f, text, timeout=t, pn=self.name(), cn='re')
v = format('%L', v) if isinstance(v, list):
irc.reply(v) v = format('%L', v)
except commands.ProcessTimeoutError as e: irc.reply(v)
irc.error("ProcessTimeoutError: %s" % (e,)) except commands.ProcessTimeoutError as e:
except re.error as e: irc.error("ProcessTimeoutError: %s" % (e,))
irc.error(e.args[0]) except re.error as e:
irc.error(e.args[0])
re = thread(wrap(re, [first('regexpMatcherMany', 'regexpReplacer'), re = thread(wrap(re, [first('regexpMatcherMany', 'regexpReplacer'),
'text'])) 'text']))