mirror of
https://github.com/pi-hole/pi-hole
synced 2024-12-22 14:58:08 +00:00
Treat FTL return data as strings (#5509)
This commit is contained in:
commit
2529fbeacd
@ -133,7 +133,7 @@ GetFTLData() {
|
||||
|
||||
if [ "${status}" = 200 ]; then
|
||||
# response OK
|
||||
echo "${data}"
|
||||
printf %s "${data}"
|
||||
elif [ "${status}" = 000 ]; then
|
||||
# connection lost
|
||||
echo "000"
|
||||
|
@ -46,14 +46,14 @@ GenerateOutput(){
|
||||
data="${1}"
|
||||
|
||||
# construct a new json for the list results where each object contains the domain and the related type
|
||||
lists_data=$(echo "${data}" | jq '.search.domains | [.[] | {domain: .domain, type: .type}]')
|
||||
lists_data=$(printf %s "${data}" | jq '.search.domains | [.[] | {domain: .domain, type: .type}]')
|
||||
|
||||
# construct a new json for the gravity results where each object contains the adlist URL and the related domains
|
||||
gravity_data=$(echo "${data}" | jq '.search.gravity | group_by(.address) | map({ address: (.[0].address), domains: [.[] | .domain] })')
|
||||
gravity_data=$(printf %s "${data}" | jq '.search.gravity | group_by(.address) | map({ address: (.[0].address), domains: [.[] | .domain] })')
|
||||
|
||||
# number of objects in each json
|
||||
num_gravity=$(echo "${gravity_data}" | jq length )
|
||||
num_lists=$(echo "${lists_data}" | jq length )
|
||||
num_gravity=$(printf %s "${gravity_data}" | jq length )
|
||||
num_lists=$(printf %s "${lists_data}" | jq length )
|
||||
|
||||
if [ "${partial}" = true ]; then
|
||||
search_type_str="partially"
|
||||
@ -66,7 +66,7 @@ GenerateOutput(){
|
||||
if [ "${num_lists}" -gt 0 ]; then
|
||||
# Convert the data to a csv, each line is a "domain,type" string
|
||||
# not using jq's @csv here as it quotes each value individually
|
||||
lists_data_csv=$(echo "${lists_data}" | jq --raw-output '.[] | [.domain, .type] | join(",")' )
|
||||
lists_data_csv=$(printf %s "${lists_data}" | jq --raw-output '.[] | [.domain, .type] | join(",")' )
|
||||
|
||||
# Generate output for each csv line, separating line in a domain and type substring at the ','
|
||||
echo "${lists_data_csv}" | while read -r line; do
|
||||
@ -79,7 +79,7 @@ GenerateOutput(){
|
||||
if [ "${num_gravity}" -gt 0 ]; then
|
||||
# Convert the data to a csv, each line is a "URL,domain,domain,...." string
|
||||
# not using jq's @csv here as it quotes each value individually
|
||||
gravity_data_csv=$(echo "${gravity_data}" | jq --raw-output '.[] | [.address, .domains[]] | join(",")' )
|
||||
gravity_data_csv=$(printf %s "${gravity_data}" | jq --raw-output '.[] | [.address, .domains[]] | join(",")' )
|
||||
|
||||
# Generate line-by-line output for each csv line
|
||||
echo "${gravity_data_csv}" | while read -r line; do
|
||||
|
@ -465,7 +465,7 @@ def test_FTL_development_binary_installed_and_responsive_no_errors(host):
|
||||
source /opt/pihole/basic-install.sh
|
||||
create_pihole_user
|
||||
funcOutput=$(get_binary_name)
|
||||
echo "development" > /etc/pihole/ftlbranch
|
||||
echo "development-v6" > /etc/pihole/ftlbranch
|
||||
binary="pihole-FTL${funcOutput##*pihole-FTL}"
|
||||
theRest="${funcOutput%pihole-FTL*}"
|
||||
FTLdetect "${binary}" "${theRest}"
|
||||
|
Loading…
Reference in New Issue
Block a user