Skip to content

Commit de0f4f7

Browse files
authored
Merge pull request #2104 from drwetter/fix_2103
Fix JSON output bc of missing locale in alpine (3.0)
2 parents a385339 + c511319 commit de0f4f7

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

testssl.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ declare -r UA_SNEAKY="Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Fi
271271
########### Initialization part, further global vars just being declared here
272272
#
273273
LC_COLLATE="" # ensures certain regex patterns work as expected and aren't localized, see setup_lc_collate()
274+
HAS_LOCALE=false
274275
PRINTF="" # which external printf to use. Empty presets the internal one, see #1130
275276
IKNOW_FNAME=false
276277
FIRST_FINDING=true # is this the first finding we are outputting to file?
@@ -17281,6 +17282,13 @@ setup_lc_collate() {
1728117282
local msg='locale(1) support for any of "C, POSIX, C.UTF-8, en_US.UTF-8, en_GB.UTF-8" missing'
1728217283
local found=false
1728317284

17285+
type -p locale &> /dev/null && HAS_LOCALE=true
17286+
if ! "$HAS_LOCALE"; then
17287+
# likely docker container or any other minimal environment. This should work(tm)
17288+
LC_COLLATE=C
17289+
return 0
17290+
fi
17291+
1728417292
for l in C POSIX C.UTF-8 en_US.UTF-8 en_GB.UTF-8; do
1728517293
locale -a | grep -q $l
1728617294
[[ $? -ne 0 ]] && continue
@@ -17290,7 +17298,7 @@ setup_lc_collate() {
1729017298
done
1729117299
if ! "$found"; then
1729217300
prln_local_problem "$msg\n"
17293-
fileout "$jsonID" "WARN" "$msg"
17301+
# we can't use fileout yet as it messes up JSON output, see #2103
1729417302
return 1
1729517303
fi
1729617304
return 0
@@ -17551,6 +17559,7 @@ HAS_GNUDATE: $HAS_GNUDATE
1755117559
HAS_FREEBSDDATE: $HAS_FREEBSDDATE
1755217560
HAS_OPENBSDDATE: $HAS_OPENBSDDATE
1755317561
HAS_SED_E: $HAS_SED_E
17562+
HAS_LOCALE: $HAS_LOCALE
1755417563

1755517564
SHOW_EACH_C: $SHOW_EACH_C
1755617565
SSL_NATIVE: $SSL_NATIVE

0 commit comments

Comments
 (0)