mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-24 11:42:52 +01:00
commands._getRe: Restore original args for any failure
String.re uses first('regexpMatcher', 'regexpReplacer'). If the args provided to String.re are not a matcher and are longer than a single IRC message (e.g., from a nested command), then regexpReplacer would never be tried. A too long error should be handled the same as running out of args while trying to find a valid regexp. Signed-off-by: James McCoy <vega.james@gmail.com>
This commit is contained in:
parent
b99ff28e33
commit
a8cd99f121
@ -1,6 +1,6 @@
|
||||
###
|
||||
# Copyright (c) 2002-2005, Jeremiah Fincher
|
||||
# Copyright (c) 2009-2010, James McCoy
|
||||
# Copyright (c) 2009-2010,2015, James McCoy
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@ -375,8 +375,8 @@ def _getRe(f):
|
||||
else:
|
||||
state.args.append(s)
|
||||
else:
|
||||
state.errorInvalid('regular expression', s)
|
||||
except IndexError:
|
||||
raise ValueError
|
||||
except (ValueError, IndexError):
|
||||
args[:] = original
|
||||
state.errorInvalid('regular expression', s)
|
||||
return get
|
||||
|
@ -1,5 +1,6 @@
|
||||
###
|
||||
# Copyright (c) 2002-2005, Jeremiah Fincher
|
||||
# Copyright (c) 2015, James McCoy
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@ -181,5 +182,9 @@ class FirstTestCase(CommandsTestCase):
|
||||
self.assertStateErrored([first('int', 'something')], ['words'],
|
||||
errored=False)
|
||||
|
||||
def testLongRegexp(self):
|
||||
spec = [first('regexpMatcher', 'regexpReplacer'), 'text']
|
||||
self.assertStateErrored(spec, ['s/foo/bar/', 'x' * 512], errored=False)
|
||||
|
||||
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user