ZF-1629: The cookie path has some problem in Zend_Http_CookieJar
Description
If using $path="/a/b/",the cookie which exsits in the path "/a/b/" will be filtered. for example:
<?php
require_once('Zend/Http/Client.php');
require_once('Zend/Http/CookieJar.php');
$params=array('continue'=>'https://google.com/a/yourdomain.com/…',
'service'=>'CPanel',
'persistent'=>'true',
'at'=>'null',
'userName'=>'admin',
'password'=>'****'
);
$client=new Zend_Http_Client();
$client->setCookieJar();
$client->setUri('https://google.com/a/yourdomain.com/…');
$client->setParameterPost($params);
$client->request('POST');
The example can not send correct Cookie.The cookie in path of "a/yourdomain.com/LoginAction/" will be lost. if i fixed Zend_Http_Cookiejar using this codes as follows:
protected function _matchPath($domains, $path) {
$ret = array();
foreach ($domains as $dom => $paths_array) {
foreach (array_keys($paths_array) as $cpath) {
$regex = "|^" . preg_quote($cpath, "|") . "|i";
if (preg_match($regex, $path."/") { //I changed the line
if (! isset($ret[$dom])) $ret[$dom] = array();
$ret[$dom][$cpath] = &$paths_array[$cpath];
}
}
}
return $ret;
}
The example will return right result.
Comments
Posted by Bill Karwin (bkarwin) on 2007-06-27T10:36:24.000+0000
Assigned to Shahar.
Posted by Shahar Evron (shahar) on 2007-06-27T10:55:38.000+0000
Thanks for the report - should be fixed in r. 5460 + unit tests added.
Posted by Anhui Lin (anhuilin) on 2007-06-28T09:00:19.000+0000
Hello, Shahar Evron
Posted by Shahar Evron (shahar) on 2007-06-28T09:33:42.000+0000
HI,
Can you attach some reproduction code?
Posted by Anhui Lin (anhuilin) on 2007-06-28T10:18:14.000+0000
Hi, This is the code.
The example will get wrong result. But I changed the code as follows:
The result will be right. Can you give me Email?Thanks!
Posted by Darby Felton (darby) on 2007-07-30T09:28:33.000+0000
Fix version after 1.0.1.
Posted by Shahar Evron (shahar) on 2009-07-25T14:14:11.000+0000
Hallelujah - after 2 years, fixed in rev. 17079
Thanks!
Posted by Satoru Yoshida (satoruyoshida) on 2009-11-17T22:58:03.000+0000
I set fix version. I find this at SVN r17118 in 1.9 branch.