3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-12-22 18:52:40 +01:00

applets/pbot-vm: disregard IRC text modifiers when escaping unprintable characters

This commit is contained in:
Pragmatic Software 2024-10-27 12:52:15 -07:00
parent f2068a4baf
commit 4a025801a2
No known key found for this signature in database
GPG Key ID: CC916B6E3C84ECCE
2 changed files with 13 additions and 3 deletions

View File

@ -373,12 +373,22 @@ sub postprocess_output($self) {
# "\n" => '<nl>',
# \t is left alone
);
$self->{output} =~ s/([\e\f])/$escapes{$1}/gs;
# other unprintables
my %disregard = ( "\n" => 1, "\r" => 1, "\t" => 1, "\x03" => 1 );
my %disregard = (
"\n" => 1, "\r" => 1, "\t" => 1,
"\x11" => 1, # monospace
"\x1D" => 1, # italic
"\x1E" => 1, # strikethrough
"\x1F" => 1, # underline
"\x02" => 1, # bold
"\x03" => 1, # colors
"\x0F" => 1, # reset
);
$self->{output} =~ s/([\x00-\x1f])/$disregard{$1} ? $1 : sprintf('\x%02X', ord $1)/gse;
}

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 => 4813,
BUILD_DATE => "2024-10-25",
BUILD_REVISION => 4814,
BUILD_DATE => "2024-10-27",
};
sub initialize {}