Skip to content

Commit ca43732

Browse files
committed
improve replacing low/high utf8 surrogates
1 parent a63f1b9 commit ca43732

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/\\ud[89a-f]\w{2}/\\ufffd/gmxi;
870+
$body =~ s/[\x{D800}-\x{DFFF}]/\x{fffd}/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/\\ud[89a-f]\w{2}/\\ufffd/gmxio;
1209+
$buf =~ s/[\x{D800}-\x{DFFF}]/\x{fffd}/gmxi;
12101210
$json_decoder->incr_parse($buf);
12111211
$remaining = $remaining -$length;
12121212
if($remaining < $length) { $length = $remaining; }

0 commit comments

Comments
 (0)