1
0
Fork 0

Fix handling of urlencoded user and password in proxy urls, fixes #2339

pull/2347/head
Jordi Boggiano 2013-10-18 11:35:09 +02:00
parent f1fd9cbd01
commit 08243ce2e3
2 changed files with 4 additions and 4 deletions

View File

@ -91,9 +91,9 @@ final class StreamContextFactory
}
if (isset($proxy['user'])) {
$auth = $proxy['user'];
$auth = urldecode($proxy['user']);
if (isset($proxy['pass'])) {
$auth .= ':' . $proxy['pass'];
$auth .= ':' . urldecode($proxy['pass']);
}
$auth = base64_encode($auth);

View File

@ -59,7 +59,7 @@ class StreamContextFactoryTest extends \PHPUnit_Framework_TestCase
public function testHttpProxy()
{
$_SERVER['http_proxy'] = 'http://username:password@proxyserver.net:3128/';
$_SERVER['http_proxy'] = 'http://username:p%40ssword@proxyserver.net:3128/';
$_SERVER['HTTP_PROXY'] = 'http://proxyserver/';
$context = StreamContextFactory::getContext('http://example.org', array('http' => array('method' => 'GET')));
@ -69,7 +69,7 @@ class StreamContextFactoryTest extends \PHPUnit_Framework_TestCase
'proxy' => 'tcp://proxyserver.net:3128',
'request_fulluri' => true,
'method' => 'GET',
'header' => array("Proxy-Authorization: Basic " . base64_encode('username:password')),
'header' => array("Proxy-Authorization: Basic " . base64_encode('username:p@ssword')),
'max_redirects' => 20,
'follow_location' => 1,
)), $options);