diff --git a/src/tool_setopt.c b/src/tool_setopt.c index b051388895..917191ef29 100644 --- a/src/tool_setopt.c +++ b/src/tool_setopt.c @@ -252,12 +252,17 @@ static char *c_escape(const char *str, curl_off_t len) strcpy(e, "\\?"); e += 2; } - else if(!ISPRINT(c)) { + else if(ISPRINT(c)) + *e++ = c; + else if(len > 1 && ISXDIGIT(s[1])) { + /* Octal escape to avoid >2 digit hex. */ + msnprintf(e, 5, "\\%03o", (unsigned)c); + e += 4; + } + else { msnprintf(e, 5, "\\x%02x", (unsigned)c); e += 4; } - else - *e++ = c; } while(cutoff--) *e++ = '.'; diff --git a/tests/data/test1465 b/tests/data/test1465 index 356b1e1b94..9703f68cf2 100644 Binary files a/tests/data/test1465 and b/tests/data/test1465 differ