3
0
mirror of https://github.com/pragma-/pbot.git synced 2025-01-23 10:34:52 +01:00

Plugins/TypoSub: limit length of s//g replacements

This commit is contained in:
Pragmatic Software 2020-02-27 14:20:42 -08:00
parent cb80857927
commit 2ef640de19

View File

@ -51,6 +51,7 @@ sub on_public {
if ($msg =~ m/^\s*s${sep}(.*?)(?<!\\)${sep}(.*?)(?<!\\)${sep}([g]*).*$/ or $msg =~ m/^\s*s${sep}(.*?)(?<!\\)${sep}(.*)$/) {
my ($regex, $replacement, $modifiers) = ($1, $2, $3);
eval {
use re::engine::RE2 -strict => 1;
my $rx = qr/$regex/;
my $messages = $self->{pbot}->{messagehistory}->{database}->get_recent_messages_from_channel($channel, 50, $self->{pbot}->{messagehistory}->{MSG_CHAT}, 'DESC');
@ -82,6 +83,7 @@ sub on_public {
defined $_ || last, ++$i, $t =~ s|[\$\\]$i|$_|g for @stuff;
$t
}gxe;
$text = substr($text, 0, 350);
} else {
$text =~ s{$rx}
{