From d824255c6ec690afa29d582cd5c5e2106a8b67e5 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Wed, 3 Aug 2022 05:18:33 -0700 Subject: [PATCH] Misc fixes and improvements applets/random_quote.pl: URI encode arguments Plugins/FuncSed: improve error handling --- applets/random_quote.pl | 3 ++- cpanfile | 1 + lib/PBot/Plugin/FuncSed.pm | 37 +++++++++++++++++++++++-------------- lib/PBot/VERSION.pm | 4 ++-- 4 files changed, 28 insertions(+), 17 deletions(-) diff --git a/applets/random_quote.pl b/applets/random_quote.pl index 50322899..c036e406 100755 --- a/applets/random_quote.pl +++ b/applets/random_quote.pl @@ -6,6 +6,7 @@ # Quick and dirty by :pragma use LWP::UserAgent::WithCache; +use URI::Escape; my ($text, $t); @@ -35,7 +36,7 @@ while (1) { my $author = ""; $arguments =~ s/\$nick/me/gi; - $arguments =~ s/\s/+/g; + $arguments = uri_escape($arguments); if ($arguments =~ m/\-\-author[\s\+]+(.*)/i) { $author = $1; diff --git a/cpanfile b/cpanfile index 2c098b6d..3871c0ba 100644 --- a/cpanfile +++ b/cpanfile @@ -389,6 +389,7 @@ feature qalc => sub { }; feature random_quote => sub { + requires 'URI::Escape'; requires 'LWP::UserAgent::WithCache'; }; diff --git a/lib/PBot/Plugin/FuncSed.pm b/lib/PBot/Plugin/FuncSed.pm index f50527bb..7ddcaec9 100644 --- a/lib/PBot/Plugin/FuncSed.pm +++ b/lib/PBot/Plugin/FuncSed.pm @@ -33,26 +33,35 @@ sub func_sed { my $self = shift; my $text = "@_"; - if ($text =~ /^s(.)(.*?)(?//[Pig]; P preserve case; i ignore case; g replace all'; } - return $a; - } else { - return "sed: syntax error"; + }; + + if (my $e = $@) { + $e =~ s/ at .*$//; + return "sed: syntax error: $e"; } + + return $result; } use warnings; diff --git a/lib/PBot/VERSION.pm b/lib/PBot/VERSION.pm index a43cd5e0..8f29bd5d 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 => 4560, - BUILD_DATE => "2022-07-14", + BUILD_REVISION => 4561, + BUILD_DATE => "2022-08-03", }; sub initialize {}