diff --git a/lib/content_encoding.c b/lib/content_encoding.c index e238507836..88446cfa0c 100644 --- a/lib/content_encoding.c +++ b/lib/content_encoding.c @@ -783,7 +783,8 @@ CURLcode Curl_build_unencoding_stack(struct Curl_easy *data, * Exception is "chunked" transfer-encoding which always must happen */ if((is_transfer && !data->set.http_transfer_encoding && !is_chunked) || (!is_transfer && data->set.http_ce_skip)) { - bool is_identity = curl_strnequal(name, "identity", 8); + bool is_identity = (namelen == 8) && + curl_strnequal(name, "identity", 8); /* not requested, ignore */ CURL_TRC_WRITE(data, "decoder not requested, ignored: %.*s", (int)namelen, name); diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index 43adb28741..17ae5ca610 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -255,7 +255,7 @@ test2080 test2081 test2082 test2083 test2084 test2085 test2086 test2087 \ test2088 test2089 test2090 test2091 test2092 test2093 test2094 \ test2100 test2101 test2102 test2103 test2104 test2105 test2106 test2107 \ test2108 test2109 test2110 test2113 test2114 test2115 test2116 test2117 \ -test2118 \ +test2118 test2119 \ \ test2200 test2201 test2202 test2203 test2204 test2205 test2206 test2207 \ test2208 \ diff --git a/tests/data/test2119 b/tests/data/test2119 new file mode 100644 index 0000000000..8f9c2ecaed --- /dev/null +++ b/tests/data/test2119 @@ -0,0 +1,54 @@ + + + + +HTTP +Transfer-Encoding + + + +# Server-side + + +HTTP/1.1 200 swsclose OK +Content-Length: 6 +Transfer-Encoding: identityx + +-foo- + + + +# Client-side + + +http + + +Reject unsolicited Transfer-Encoding token with an identity prefix + +# no --tr-encoding, so any transfer-coding other than chunked/identity is +# unsolicited and must be rejected + +http://%HOSTIP:%HTTPPORT/%TESTNUMBER -sS + + + +# Verify data after the test has been "shot" + + +GET /%TESTNUMBER HTTP/1.1 +Host: %HOSTIP:%HTTPPORT +User-Agent: curl/%VERSION +Accept: */* + + + +# CURLE_BAD_CONTENT_ENCODING is 61 + +61 + + +curl: (61) Unsolicited Transfer-Encoding (identityx) found + + +