From 494d193ec5a56c409df134693959432b83f0cdf0 Mon Sep 17 00:00:00 2001 From: Jeremy Booker Date: Thu, 19 May 2016 11:14:53 -0400 Subject: [PATCH] Use grep -Po for parsing JSON response When parsing the JSON response from the HTTP request to create a new certificate... Use `grep -Po` instead of `egrep` as egrep is not matching across all the lines we need to match. Also trim leading whitespace from `token` by passing it through `tr`. --- getssl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/getssl b/getssl index c5e4395..d861c36 100755 --- a/getssl +++ b/getssl @@ -872,11 +872,11 @@ for d in $alldomains; do else # set up the correct http token for verification # get the http component of the ACME response - http01=$(echo "$response" | egrep -o '{[^{]*"type":"http-01"[^}]*') + http01=$(echo "$response" | grep -Po '{\n.*"type": "http-01"([^}]*\n)*') debug http01 "$http01" # get the token from the http component - token=$(echo "$http01" | sed 's/,/\n'/g| grep '"token":'| cut -d : -f 2|sed 's/"//g') + token=$(echo "$http01" | sed 's/,/\n'/g| grep '"token":'| cut -d : -f 2|sed 's/"//g' | tr -d ' ') debug token "$token" uri=$(echo "$http01" | sed 's/,/\n'/g| grep '"uri":'| cut -d : -f 2,3|sed 's/"//g')