3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-05 11:39:34 +01:00

Factoids: fix Unicode issue with factfind

This commit is contained in:
Pragmatic Software 2022-06-25 17:34:06 -07:00
parent c0ade8a2f6
commit 5619d30a1b
3 changed files with 10 additions and 4 deletions

View File

@ -1076,6 +1076,12 @@ sub cmd_factinfo {
return "/say $context->{arguments} is not a factoid or an applet.";
}
sub quotemeta2 {
my ($text) = @_;
$text =~ s/(?!\\)([\[\\\|(){^\$*+?.])/\\$1/g;
return $text;
}
sub cmd_factfind {
my ($self, $context) = @_;
@ -1141,7 +1147,7 @@ sub cmd_factfind {
$regex = $arguments;
} else {
$regex = ($arguments =~ m/^\w/) ? '\b' : '\B';
$regex .= quotemeta $arguments;
$regex .= quotemeta2 $arguments;
$regex .= ($arguments =~ m/\w$/) ? '\b' : '\B';
}

View File

@ -121,7 +121,7 @@ sub interpreter {
my $namespace_regex = $namespace;
if ($strictnamespace) { $namespace_regex = "(?:" . (quotemeta $namespace) . '|\\.\\*)'; }
$context->{arguments} = quotemeta($original_keyword) . " -channel $namespace_regex";
$context->{arguments} = "$original_keyword -channel $namespace_regex";
my $matches = $self->{pbot}->{commands}->{modules}->{Factoids}->cmd_factfind($context);
# found factfind matches

View File

@ -25,8 +25,8 @@ use PBot::Imports;
# These are set by the /misc/update_version script
use constant {
BUILD_NAME => "PBot",
BUILD_REVISION => 4536,
BUILD_DATE => "2022-05-22",
BUILD_REVISION => 4544,
BUILD_DATE => "2022-06-25",
};
sub initialize {}