mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-23 17:10:47 +01:00
SedRegex: make the regexp process timeout configurable
Although the default has been adequate on my systems, busy or low-powered machines may fail to process regexps quickly enough and cause SedRegex to sporadically error.
Reported by @cottongin via IRC.
From: 51ff41251b
This commit is contained in:
parent
fd7aa571e9
commit
e831d0e8ec
@ -56,5 +56,13 @@ conf.registerChannelValue(SedRegex, 'enable',
|
||||
conf.registerChannelValue(SedRegex, 'ignoreRegex',
|
||||
registry.Boolean(True, _("""Should Perl/sed regex replacing
|
||||
ignore messages which look like valid regex?""")))
|
||||
conf.registerGlobalValue(SedRegex, 'processTimeout',
|
||||
registry.PositiveFloat(0.05, _("""Sets the timeout when processing a single
|
||||
regexp. The default should be adequate unless
|
||||
you have a busy or low-powered system that
|
||||
cannot process regexps quickly enough. However,
|
||||
you will not want to set this value too high
|
||||
as that would make your bot vulnerable to ReDoS
|
||||
attacks.""")))
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
||||
|
@ -153,7 +153,8 @@ class SedRegex(callbacks.PluginRegexp):
|
||||
else:
|
||||
messageprefix = '%s thinks %s' % (msg.nick, m.nick)
|
||||
try:
|
||||
if regexp_wrapper(text, pattern, timeout=0.05, plugin_name=self.name(),
|
||||
regex_timeout = self.registryValue('processTimeout')
|
||||
if regexp_wrapper(text, pattern, timeout=regex_timeout, plugin_name=self.name(),
|
||||
fcn_name='replacer'):
|
||||
if self.registryValue('boldReplacementText', msg.args[0]):
|
||||
replacement = ircutils.bold(replacement)
|
||||
|
Loading…
x
Reference in New Issue
Block a user