Problems with username or pass with colon when setting CURLOPT_USERPWD

后端 未结 3 900
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-19 06:40

We are trying to use curl in PHP5 to login to a website using basic authentication.

Partial code is like this:



        
3条回答
  •  醉酒成梦
    2020-12-19 07:03

    I looked up the implementation of extraction of CURLOPT_USERPWD in curl code, This is how its done There is a forward searh on the username-passwd string, looking for the ":" character. And then username and passwd are extracted (the string before : is username and the string after : is passwd)

    So, as you would have guessed, if the username string contains a : character, all this will fail. However as the chances of the : character being as part of username are considerably less, this is not reported as a bug.

    thanks

提交回复
热议问题