简体   繁体   English

PHP curl_setopt()错误无效字符

[英]PHP curl_setopt() error invalid characters

I have some code of a website in which cURL is used (not quite "mine"..part of an open source project) and after loading up the site on localhost of my VM for the first time in months because I want to help with a recent issue that has arisen, which is unrelated to cURL, I had fixed one local problem which was obvious to me and now when trying to log in to the site I get this error 我有一些使用cURL的网站的代码(不是开源项目的“我的”。部分),并且在几个月后第一次将网站加载到我的VM的localhost后,因为我想提供帮助最近出现了一个与cURL无关的问题,我已经解决了一个本地问题,这对我来说很明显,现在当尝试登录该站点时出现此错误

curl_setopt(): Curl option contains invalid characters (\0)

Whatever I have messed up though, this seems to happen trying to load any page not just login page. 无论我如何搞乱,尝试加载任何页面而不只是登录页面似乎都会发生。 This is the line of code it points to 这是它指向的代码行

curl_setopt($re, CURLOPT_COOKIE, "slim_session=".$_COOKIE['slim_session'].";");

If it helps, through error_log() 'ing I found that the value of $_COOKIE['slim_session'] is a:4:{s:10:"slim.flash";a:0:{}s:11:"AccessToken";O:48:"SolasMatch\\\\Common\\\\Protobufs\\\\Models\\\\OAuthResponse":4:{s:8:" 如果有帮助,通过error_log()发现$_COOKIE['slim_session']值为a:4:{s:10:"slim.flash";a:0:{}s:11:"AccessToken";O:48:"SolasMatch\\\\Common\\\\Protobufs\\\\Models\\\\OAuthResponse":4:{s:8:"

Unfortunately cURL is not my strong suit, but I can provide more info on the situation as needed. 不幸的是,cURL不是我的强项,但是我可以根据需要提供有关情况的更多信息。 You can see the full function the above code is from here . 您可以从此处查看以上代码的完整功能。

The problem is that protected properties are serialised in a special way, ie: 问题在于,受保护的属性以特殊方式序列化,即:

s:14:"\000*\000_descriptor";N

And those null characters are disallowed when setting cURL options as part of the changes made due to this security issue . 并且由于此安全问题而将cURL选项设置为所做更改的一部分时,不允许使用这些空字符。

Passing serialised objects in this manner is risky, unless the values are either coming from a trusted source or bear a tamper proof signature. 除非值来自受信任的来源或带有防篡改签名,否则以这种方式传递序列化的对象是有风险的。 You may be able to make it work by first URL encoding the serialised value. 您可能可以通过首先对序列化的值进行URL编码来使其工作。

curl_setopt($re, CURLOPT_COOKIE, "slim_session=" . urlencode($_COOKIE['slim_session']) . ";");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM