mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-25 21:39:27 +01:00
pbot-vm: use %02X for escapes; do not escape \x03 (for IRC colors)
This commit is contained in:
parent
d3328a4acd
commit
4b5d8aa535
@ -154,11 +154,11 @@ sub gdbmi_to_hash($text, $makejson = 1) {
|
|||||||
$text =~ s/\\+(\d{3})/$1 >= 0x20 ? chr oct $1 : "\\\\$1"/ge;
|
$text =~ s/\\+(\d{3})/$1 >= 0x20 ? chr oct $1 : "\\\\$1"/ge;
|
||||||
|
|
||||||
# escape malformed unicode
|
# 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);
|
$text = encode('UTF-8', $octets, Encode::FB_CROAK);
|
||||||
|
|
||||||
# escape invalid JSON characters
|
# 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
|
# return hashtable decoded from json
|
||||||
my $result = eval { decode_json("{$text}") };
|
my $result = eval { decode_json("{$text}") };
|
||||||
|
@ -317,7 +317,7 @@ sub execute {
|
|||||||
if ($line =~ /^result:/) {
|
if ($line =~ /^result:/) {
|
||||||
$line =~ s/^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);
|
$line = encode('UTF-8', $octets, Encode::FB_CROAK);
|
||||||
|
|
||||||
my $compile_out = decode_json($line);
|
my $compile_out = decode_json($line);
|
||||||
@ -382,8 +382,8 @@ sub postprocess_output($self) {
|
|||||||
$self->{output} =~ s/([\e\f])/$escapes{$1}/gs;
|
$self->{output} =~ s/([\e\f])/$escapes{$1}/gs;
|
||||||
|
|
||||||
# other unprintables
|
# other unprintables
|
||||||
my %disregard = ( "\n" => 1, "\r" => 1, "\t" => 1 );
|
my %disregard = ( "\n" => 1, "\r" => 1, "\t" => 1, "\x03" => 1 );
|
||||||
$self->{output} =~ s/([\x00-\x1f])/$disregard{$1} ? $1 : sprintf('\x%X', ord $1)/gse;
|
$self->{output} =~ s/([\x00-\x1f])/$disregard{$1} ? $1 : sprintf('\x%02X', ord $1)/gse;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub show_output($self) {
|
sub show_output($self) {
|
||||||
|
@ -25,7 +25,7 @@ use PBot::Imports;
|
|||||||
# These are set by the /misc/update_version script
|
# These are set by the /misc/update_version script
|
||||||
use constant {
|
use constant {
|
||||||
BUILD_NAME => "PBot",
|
BUILD_NAME => "PBot",
|
||||||
BUILD_REVISION => 4532,
|
BUILD_REVISION => 4533,
|
||||||
BUILD_DATE => "2022-04-08",
|
BUILD_DATE => "2022-04-08",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user