Skip to content

Commit

Permalink
improve replacing utf surragotes
Browse files Browse the repository at this point in the history
  • Loading branch information
sni committed Feb 20, 2024
1 parent ca43732 commit 8a926e3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/Monitoring/Livestatus.pm
Expand Up @@ -867,7 +867,7 @@ sub _send {
# surrogate pair expected
if($@) {
# replace u+D800 to u+DFFF (reserved utf-16 low/high surrogates)
$body =~ s/[\x{D800}-\x{DFFF}]/\x{fffd}/gmxi;
$body =~ s/\\ud[89a-f][0-9a-f]{2}/\\ufffd/gmxi;
eval {
$result = $json_decoder->decode($body);
};
Expand Down Expand Up @@ -1206,7 +1206,7 @@ sub _read_socket_do {
if($remaining < $length) { $length = $remaining; }
while($length > 0 && $sock->read(my $buf, $length)) {
# replace u+D800 to u+DFFF (reserved utf-16 low/high surrogates)
$buf =~ s/[\x{D800}-\x{DFFF}]/\x{fffd}/gmxi;
$buf =~ s/\\ud[89a-f][0-9a-f]{2}/\\ufffd/gmxi;
$json_decoder->incr_parse($buf);
$remaining = $remaining -$length;
if($remaining < $length) { $length = $remaining; }
Expand Down

0 comments on commit 8a926e3

Please sign in to comment.