From 4b5d8aa535a433afdf3b659d99278ef490fdb7e7 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Fri, 8 Apr 2022 13:12:37 -0700 Subject: [PATCH] pbot-vm: use %02X for escapes; do not escape \x03 (for IRC colors) --- applets/pbot-vm/guest/bin/guest-gdb | 4 ++-- applets/pbot-vm/host/lib/Languages/_default.pm | 6 +++--- lib/PBot/VERSION.pm | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/applets/pbot-vm/guest/bin/guest-gdb b/applets/pbot-vm/guest/bin/guest-gdb index c281b3c0..07490996 100755 --- a/applets/pbot-vm/guest/bin/guest-gdb +++ b/applets/pbot-vm/guest/bin/guest-gdb @@ -154,11 +154,11 @@ sub gdbmi_to_hash($text, $makejson = 1) { $text =~ s/\\+(\d{3})/$1 >= 0x20 ? chr oct $1 : "\\\\$1"/ge; # escape malformed unicode - my $octets = decode('UTF-8', $text, sub { sprintf '\\\\x%X', shift }); + my $octets = decode('UTF-8', $text, sub { sprintf '\\\\x%02X', shift }); $text = encode('UTF-8', $octets, Encode::FB_CROAK); # escape invalid JSON characters - $text =~ s/([\x10-\x1f])/sprintf '\\\\x%X', ord $1/ge; + $text =~ s/([\x10-\x1f])/sprintf '\\\\x%02X', ord $1/ge; # return hashtable decoded from json my $result = eval { decode_json("{$text}") }; diff --git a/applets/pbot-vm/host/lib/Languages/_default.pm b/applets/pbot-vm/host/lib/Languages/_default.pm index a5fccb9f..a8350f9e 100755 --- a/applets/pbot-vm/host/lib/Languages/_default.pm +++ b/applets/pbot-vm/host/lib/Languages/_default.pm @@ -317,7 +317,7 @@ sub execute { if ($line =~ /^result:/) { $line =~ s/^result://; - my $octets = decode('UTF-8', $line, sub { sprintf '\\\\x%X', shift }); + my $octets = decode('UTF-8', $line, sub { sprintf '\\\\x%02X', shift }); $line = encode('UTF-8', $octets, Encode::FB_CROAK); my $compile_out = decode_json($line); @@ -382,8 +382,8 @@ sub postprocess_output($self) { $self->{output} =~ s/([\e\f])/$escapes{$1}/gs; # other unprintables - my %disregard = ( "\n" => 1, "\r" => 1, "\t" => 1 ); - $self->{output} =~ s/([\x00-\x1f])/$disregard{$1} ? $1 : sprintf('\x%X', ord $1)/gse; + my %disregard = ( "\n" => 1, "\r" => 1, "\t" => 1, "\x03" => 1 ); + $self->{output} =~ s/([\x00-\x1f])/$disregard{$1} ? $1 : sprintf('\x%02X', ord $1)/gse; } sub show_output($self) { diff --git a/lib/PBot/VERSION.pm b/lib/PBot/VERSION.pm index 3201f41e..6cd3568d 100644 --- a/lib/PBot/VERSION.pm +++ b/lib/PBot/VERSION.pm @@ -25,7 +25,7 @@ use PBot::Imports; # These are set by the /misc/update_version script use constant { BUILD_NAME => "PBot", - BUILD_REVISION => 4532, + BUILD_REVISION => 4533, BUILD_DATE => "2022-04-08", };