PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » HTTP » HTTP_Request » Bug #1305

addCookie() incorrectly calls urlencode()

Details

Submitted2004-04-28 07:11 UTC
Fromcardoe at cardoe dot com
StatusNo Feedback
PackageHTTP_Request
PHP VersionIrrelevant
OSLinux
Roadmaps(Not assigned)

Comments

[2004-04-28 07:11 UTC] cardoe at cardoe dot com

Description:
------------
addCookie() on line 508 in Request.php currently calls urlencode() on the cookie name and value. This appears incorrect as Firefox and Mozilla do not exhibit this behavior and their server processes the cookie correctly. However Request.php urlencode()'s the data and the server does not process the data correctly.

You can see the <a href='http://www.cardoe.com/gentoo/phptestcase/correctCookie.png'>correct Cookie</a> in an Ethereal output. This was captured from a Firefox request (as can be seen from the screenshot).

Here is the <a href='http://www.cardoe.com/gentoo/phptestcase/wrongCookie.png'>wrong cookie</a> in Ethereal. This is captured while the PHP script made it's request (as can been seen from the screenshot).

I realize there's bug #1080 that shows that this stuff has been removed and the bug closed. But I don't know if that's for the CVS version or a previous version and this bug came back into the code or what. That's why there's the repost.

Reproduce code:
---------------
include("HTTP/Request.php");

$_req =& new HTTP_Request("");
$_req->addCookie("MyCookie", "mydata=2&mydate=This Is A Date");

$_req->setURL("http://www.google.com");
$_req->setMethod(HTTP_REQUEST_METHOD_GET);
$_req->sendRequest();

Expected result:
----------------
Cookie gets sent with the value as is.... i.e. the header looks like...

Cookie: MyCookie=mydata=2&mydate=This Is A Date\r\n

Actual result:
--------------
header value looks like...

Cookie: MyCookie=mydata%3d2%26mydate%3dThis+Is+A+Date\r\n

[2004-04-28 07:12 UTC] cardoe at cardoe dot com

URLs aren't really clickable... (before someone screams they're broken....)

http://www.cardoe.com/gentoo/phptestcase/correctCookie.png

http://www.cardoe.com/gentoo/phptestcase/wrongCookie.png