Curl - Exclamation mark in User Auth/Password

2019-02-05 14:18发布

问题:

Having a problem with CURL and the HTTP User and password Auth methods, it is not liking the exclamation mark, I've tried escaping the following ways:

Tried and failed...

/usr/bin/curl -u 'UserName\WithSlash:PasswordWithExclamation!' https://test.com/
/usr/bin/curl -u UserName\\WithSlash:PasswordWithExclamation\! https://test.com/

Not working for basic or digest if it matters (using --anyauth) ... getting 401 denied...

What am I doing incorrectly?

回答1:

 curl -u UserName\\WithSlash:PasswordWithExclamation\!  http://....

works fine.

it sends

 GET / HTTP/1.1
 Authorization: Basic VXNlck5hbWVcV2l0aFNsYXNoOlBhc3N3b3JkV2l0aEV4Y2xhbWF0aW9uIQ==
 User-Agent: curl/7.21.0
 Host: teststuff1.com:80
 Accept: */*

which is "UserName\WithSlash:PasswordWithExclamation!" in the auth string.