From 3e952e6892d7024f8105324b84b5a5d50452083a Mon Sep 17 00:00:00 2001 From: Austin H <8563086+a93h@users.noreply.github.com> Date: Tue, 17 Aug 2021 11:44:37 -0400 Subject: [PATCH] Cloudflare Fix Cloudflare was returning values not being matched properly by the regex expression. Numbers that were not Headers. This fix or patch should resolve that issue, by only collecting one match to JSON relevant data. --- ddclient.in | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ddclient.in b/ddclient.in index 5a35d38..9182ea6 100755 --- a/ddclient.in +++ b/ddclient.in @@ -5561,8 +5561,8 @@ sub nic_cloudflare_update { } # Strip header - $reply =~ s/^.*?\n\n//s; - my $response = eval {decode_json($reply)}; + $reply =~ qr/{(?:[^{}]*|(?R))*}/mp; + my $response = eval {decode_json(${^MATCH})}; unless ($response && $response->{result}) { failed("updating %s: invalid json or result.", $domain); next; @@ -5598,8 +5598,8 @@ sub nic_cloudflare_update { next; } # Strip header - $reply =~ s/^.*?\n\n//s; - $response = eval {decode_json($reply)}; + $reply =~ qr/{(?:[^{}]*|(?R))*}/mp; + $response = eval {decode_json(${^MATCH})}; unless ($response && $response->{result}) { failed("updating %s: invalid json or result.", $domain); next; @@ -5625,8 +5625,8 @@ sub nic_cloudflare_update { next; } # Strip header - $reply =~ s/^.*?\n\n//s; - $response = eval {decode_json($reply)}; + $reply =~ qr/{(?:[^{}]*|(?R))*}/mp; + $response = eval {decode_json(${^MATCH})}; if ($response && $response->{result}) { success("updating %s: IPv$ipv address set to %s", $domain, $ip); $config{$domain}{"ipv$ipv"} = $ip;