content_encoding: return 'identity' if none other exists

This fixes a regression and accidental changed behavior shipped in
8.18.0 (via 6b9c75e219).

When the setopt is set to "" and curl is built without support for a
single compression algorithm, it used to use "identity" but recently did
not.

Spotted by Codex Security
Closes #20805
This commit is contained in:
Daniel Stenberg 2026-03-03 23:06:24 +01:00
parent d7e4473806
commit 27c3e0839a
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2

View file

@ -622,6 +622,9 @@ char *Curl_get_content_encodings(void)
result = curlx_dyn_add(&enc, ce->name);
}
}
if(!result && !curlx_dyn_len(&enc))
result = curlx_dyn_add(&enc, CONTENT_ENCODING_DEFAULT);
if(!result)
return curlx_dyn_ptr(&enc);
return NULL;