[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Regression in fix for php bug #68739



Hi,

the fix for PHP bug #68739 breaks cURL cookie handling. 

Test script (fill in right domain, run under webserver, view in browser):

    <?php error_reporting(E_ALL); ini_set('display_errors', '1');

    if (!isset($_GET["setcookie"])):
        $cookies = "/tmp/cookies.txt";
        $process = 
curl_init("http://testserver.domain/test_curl.php?setcookie=1";);
        curl_setopt($process, CURLOPT_HEADER, 1);
        curl_setopt($process, CURLOPT_COOKIEFILE, $cookies);
        curl_setopt($process, CURLOPT_COOKIEJAR, $cookies);
        curl_setopt($process, CURLOPT_RETURNTRANSFER, 1);
        $return = curl_exec($process);
        curl_close($process);

            $text=str_replace("><",">\n<",$return);
            $text=str_replace("\t"," &nbsp; &nbsp; ",str_replace(" 
","&nbsp;",str_replace("\n","<br>",str_replace("<","&lt;",str_replace(">","&gt;",
$text)))));
            echo ("<br /><b>CURL return:</b><br><i>".
$text."</i><br><br>-------- cURL END ---------<br>");

            // SHOW COOKIE
            if (!file_exists($cookies)):
                    echo "<br><b>File $cookies does not exist!</b>";
            else:
                    echo "<br>Current content of cookie file: 
<br>".file_get_contents($cookies)."";
            endif;


    else: 
            setcookie("cookie","nastaveno",time()+3600);
            if (isset($_COOKIE["cookie"]) && $_COOKIE["cookie"])
                    echo "Cookie in request: \"".$_COOKIE["cookie"]."\"";
            else
                    echo "(There was no cookie in request.) ";
            echo "\n"."Cookie was sent from server to client.";
    endif;


It should print something like


CURL return:
HTTP/1.1 200 OK
Date: Mon, 02 Feb 2015 12:53:04 GMT
Server: Apache/2.2.16 (Debian)
X-Powered-By: PHP/5.3.3-7+squeeze24
Set-Cookie: cookie=nastaveno; expires=Mon, 02-Feb-2015 13:53:04 GMT
Vary: Accept-Encoding
Content-Length: 69
Content-Type: text/html

Cookie in request: "nastaveno"
Cookie was sent from server to client.

-------- cURL END ---------

Current content of cookie file:
# Netscape HTTP Cookie File # http://curl.haxx.se/rfc/cookie_spec.html # This 
file was generated by libcurl! Edit at your own risk. 46.234.116.154 FALSE / 
FALSE 1422885184 cookie nastaveno 


but with 5.3.3-7+squeeze24 the file /tmp/cookies.txt is not created and cookie 
not sent.  I compiled PHP without this fix and the bug disappeared.

I already notified the upstream (at least I hope; my comment is not showing up, 
but it could await moderation).



-- Zdeněk Bělehrádek


Reply to: