Skip to content

Commit 8a926e3

Browse files
committed
improve replacing utf surragotes
1 parent ca43732 commit 8a926e3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/Monitoring/Livestatus.pm

+2-2
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ sub _send {
867867
# surrogate pair expected
868868
if($@) {
869869
# replace u+D800 to u+DFFF (reserved utf-16 low/high surrogates)
870-
$body =~ s/[\x{D800}-\x{DFFF}]/\x{fffd}/gmxi;
870+
$body =~ s/\\ud[89a-f][0-9a-f]{2}/\\ufffd/gmxi;
871871
eval {
872872
$result = $json_decoder->decode($body);
873873
};
@@ -1206,7 +1206,7 @@ sub _read_socket_do {
12061206
if($remaining < $length) { $length = $remaining; }
12071207
while($length > 0 && $sock->read(my $buf, $length)) {
12081208
# replace u+D800 to u+DFFF (reserved utf-16 low/high surrogates)
1209-
$buf =~ s/[\x{D800}-\x{DFFF}]/\x{fffd}/gmxi;
1209+
$buf =~ s/\\ud[89a-f][0-9a-f]{2}/\\ufffd/gmxi;
12101210
$json_decoder->incr_parse($buf);
12111211
$remaining = $remaining -$length;
12121212
if($remaining < $length) { $length = $remaining; }

0 commit comments

Comments
 (0)