From 5619d30a1b0aae8c02a32f60c957a1ef51639601 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Sat, 25 Jun 2022 17:34:06 -0700 Subject: [PATCH] Factoids: fix Unicode issue with factfind --- lib/PBot/Core/Commands/Factoids.pm | 8 +++++++- lib/PBot/Core/Factoids/Interpreter.pm | 2 +- lib/PBot/VERSION.pm | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/PBot/Core/Commands/Factoids.pm b/lib/PBot/Core/Commands/Factoids.pm index 054d7c4d..7ac9fcaa 100644 --- a/lib/PBot/Core/Commands/Factoids.pm +++ b/lib/PBot/Core/Commands/Factoids.pm @@ -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'; } diff --git a/lib/PBot/Core/Factoids/Interpreter.pm b/lib/PBot/Core/Factoids/Interpreter.pm index 28b466b2..0cef24db 100644 --- a/lib/PBot/Core/Factoids/Interpreter.pm +++ b/lib/PBot/Core/Factoids/Interpreter.pm @@ -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 diff --git a/lib/PBot/VERSION.pm b/lib/PBot/VERSION.pm index 41e79a65..0fb8a9d7 100644 --- a/lib/PBot/VERSION.pm +++ b/lib/PBot/VERSION.pm @@ -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 {}