diff --git a/src/Curl/Curl.php b/src/Curl/Curl.php index afd41d3..dbca6f6 100644 --- a/src/Curl/Curl.php +++ b/src/Curl/Curl.php @@ -535,7 +535,7 @@ class Curl public function setCookie($key, $value) { $this->cookies[$key] = $value; - $this->setOpt(CURLOPT_COOKIE, str_replace('+', '%20', http_build_query($this->cookies, '', '; '))); + $this->setOpt(CURLOPT_COOKIE, str_replace(' ', '%20', urldecode(http_build_query($this->cookies, '', '; ')))); } /** diff --git a/tests/PHPCurlClass/PHPCurlClassTest.php b/tests/PHPCurlClass/PHPCurlClassTest.php index 5055751..ae16a2a 100644 --- a/tests/PHPCurlClass/PHPCurlClassTest.php +++ b/tests/PHPCurlClass/PHPCurlClassTest.php @@ -603,7 +603,7 @@ class CurlTest extends PHPUnit_Framework_TestCase ))); } - public function testCookieEncoding() + public function testCookieEncodingSpace() { $curl = new Curl(); $curl->setCookie('cookie', 'Om nom nom nom'); @@ -615,6 +615,18 @@ class CurlTest extends PHPUnit_Framework_TestCase $this->assertEquals('cookie=Om%20nom%20nom%20nom', $options[CURLOPT_COOKIE]); } + public function testCookieEncodingColon() + { + $curl = new Curl(); + $curl->setCookie('JSESSIONID', '0000wd-PcsB3bZ-KzYGAqm_rKlm:17925chrl'); + + $reflectionClass = new ReflectionClass('\Curl\Curl'); + $reflectionProperty = $reflectionClass->getProperty('options'); + $reflectionProperty->setAccessible(true); + $options = $reflectionProperty->getValue($curl); + $this->assertEquals('JSESSIONID=0000wd-PcsB3bZ-KzYGAqm_rKlm:17925chrl', $options[CURLOPT_COOKIE]); + } + public function testCookieFile() { $cookie_file = dirname(__FILE__) . '/cookies.txt';