ID: 48550 Updated by: j...@php.net Reported By: victorepand at gmail dot com -Status: Open +Status: Bogus Bug Type: cURL related Operating System: FreeBSD PHP Version: 5.2.9 New Comment:
Well, browsers do a lot of thing automatically you need to do yourself when you do it yourself. This is obviously not any bug. (tested with curl on command line with same result..) Previous Comments: ------------------------------------------------------------------------ [2009-06-15 15:50:10] victorepand at gmail dot com The error returned by cURL is: 22 The requested URL returned error: 404 I created this function which solves the problem: function urlencode_url($url) { if (!($ei=strpos($url,"?"))) $ei=strlen($url); $newurl=str_replace(array("%3A","%2F"),array(":","/"),urlencode(urldecode(substr($url,0,$ei)))).substr($url,$ei); return $newurl; } By passing the URL through this function, the offending character is converted to its urlencoded equivalent (%##). With these codes instead of the bad character, cURL reads the URL with no problem. Nonetheless, I reported this issue because Internet Explorer does not require the urlencoded codes. It loads the original URL with no problem, using the original bad character in the URL. Therefore, the cURL behavior is more strict in its requirement of the URL being urlencoded than Internet Explorer is. Perhaps cURL could automatically urlencode the URL, or perhaps a function should be made for this purpose like the one I have shown above. ------------------------------------------------------------------------ [2009-06-15 14:31:33] j...@php.net What error does it give? See http://www.php.net/curl_error ------------------------------------------------------------------------ [2009-06-14 17:13:56] victorepand at gmail dot com Description: ------------ cURL does not work when the URL has a ’ character in it. Such as, for example, this one: http://www.motorcycle-superstore.com/ProductImages/60/2009_GMax_Women’s_GM17_Derk_Open-Face_Helmet.jpg Reproduce code: --------------- $ch=curl_init(); $url="http://www.motorcycle-superstore.com/ProductImages/60/2009_GMax_Women’s_GM17_Derk_Open-Face_Helmet.jpg" curl_setopt($ch,CURLOPT_URL,$url); $result=curl_exec ($ch); Expected result: ---------------- thumbnail image in binary stored in result Actual result: -------------- curl error ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=48550&edit=1