bash Curl - 用户身份验证/密码中的感叹号

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11444347/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 22:24:41  来源:igfitidea点击:

Curl - Exclamation mark in User Auth/Password

bashcurlescaping

提问by MichaelICE

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:

CURL 和 HTTP 用户和密码 Auth 方法有问题,它不喜欢感叹号,我尝试通过以下方式转义:

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...

如果重要,则不适用于基本或摘要(使用 --anyauth)... 401 被拒绝...

What am I doing incorrectly?

我做错了什么?

回答by pizza

 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.

这是“UserName\WithSlash:PasswordWithExclamation!” 在身份验证字符串中。