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

pbot-vm: fix parsing of quoted text within GDB/MI

This commit is contained in:
Pragmatic Software 2022-04-06 10:53:07 -07:00
parent 7b9971294a
commit 3375580a2d
2 changed files with 11 additions and 4 deletions

View File

@ -146,7 +146,7 @@ sub gdb_read_result($out) {
# convert gdb/mi text to hashtable, converting to JSON first if necessary # convert gdb/mi text to hashtable, converting to JSON first if necessary
sub gdbmi_to_hash($text, $makejson = 1) { sub gdbmi_to_hash($text, $makejson = 1) {
# convert to JSON first if necessary (gdb/mi is nearly JSON already!) # convert to JSON first if necessary (gdb/mi is nearly JSON already!)
$text =~ s/([\w-]+)=/"$1":/g if $makejson; $text =~ s/"(?:[^"\\]|\\.)*"(*SKIP)(*F)|([\w-]+)=/"$1":/g if $makejson;
# decode gdb octal escapes # decode gdb octal escapes
# (sometimes \\123, othertimes \123 and I can't be arsed to investigate # (sometimes \\123, othertimes \123 and I can't be arsed to investigate
@ -161,7 +161,14 @@ sub gdbmi_to_hash($text, $makejson = 1) {
$text =~ s/([\x10-\x1f])/sprintf '\\\\x%X', ord $1/ge; $text =~ s/([\x10-\x1f])/sprintf '\\\\x%X', ord $1/ge;
# return hashtable decoded from json # return hashtable decoded from json
return decode_json("{$text}"); my $result = eval { decode_json("{$text}") };
if ($@) {
print "Error parsing GDB/MI: $@ (input: $text)\n";
exit 1;
}
return $result;
} }
sub parse_gdbmi_output($line) { sub parse_gdbmi_output($line) {

View File

@ -25,8 +25,8 @@ 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 => 4526, BUILD_REVISION => 4528,
BUILD_DATE => "2022-04-04", BUILD_DATE => "2022-04-06",
}; };
sub initialize {} sub initialize {}