From 2d9a6fcc19c8bf023f981350e0f7670d3cb1ac5c Mon Sep 17 00:00:00 2001 From: Simon Terrien Date: Fri, 26 Oct 2012 12:03:13 +0300 Subject: [PATCH 01/16] Use Norm Data instead of Data This listener is triggered when normalized data are binded. We have to use $event->getForm()->getNormData() instead of $event->getForm()->getData(). --- .../Doctrine/Form/EventListener/MergeCollectionListener.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bridge/Doctrine/Form/EventListener/MergeCollectionListener.php b/src/Symfony/Bridge/Doctrine/Form/EventListener/MergeCollectionListener.php index eaabcfc991..fb0d43bae2 100644 --- a/src/Symfony/Bridge/Doctrine/Form/EventListener/MergeCollectionListener.php +++ b/src/Symfony/Bridge/Doctrine/Form/EventListener/MergeCollectionListener.php @@ -33,7 +33,7 @@ class MergeCollectionListener implements EventSubscriberInterface public function onBindNormData(FilterDataEvent $event) { - $collection = $event->getForm()->getData(); + $collection = $event->getForm()->getNormData(); $data = $event->getData(); if (!$collection) { From 32dc31eceb344c7211fce675942be7103e4de381 Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Wed, 14 Nov 2012 19:33:51 +0100 Subject: [PATCH 02/16] [SecurityBundle] Convert Http method to uppercase in the config --- .../DependencyInjection/SecurityExtension.php | 8 ++++++-- .../DependencyInjection/Fixtures/php/container1.php | 2 +- .../DependencyInjection/Fixtures/xml/container1.xml | 2 +- .../DependencyInjection/Fixtures/yml/container1.yml | 2 +- .../Tests/DependencyInjection/SecurityExtensionTest.php | 9 +++++++++ 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php index c32e383239..adda788aad 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php @@ -177,7 +177,7 @@ class SecurityExtension extends Extension $container, $access['path'], $access['host'], - count($access['methods']) === 0 ? null : $access['methods'], + $access['methods'], $access['ip'] ); @@ -536,7 +536,7 @@ class SecurityExtension extends Extension return $switchUserListenerId; } - private function createRequestMatcher($container, $path = null, $host = null, $methods = null, $ip = null, array $attributes = array()) + private function createRequestMatcher($container, $path = null, $host = null, $methods = array(), $ip = null, array $attributes = array()) { $serialized = serialize(array($path, $host, $methods, $ip, $attributes)); $id = 'security.request_matcher.'.md5($serialized).sha1($serialized); @@ -545,6 +545,10 @@ class SecurityExtension extends Extension return $this->requestMatchers[$id]; } + if ($methods) { + $methods = array_map('strtoupper', (array) $methods); + } + // only add arguments that are necessary $arguments = array($path, $host, $methods, $ip, $attributes); while (count($arguments) > 0 && !end($arguments)) { diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/container1.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/container1.php index f5ef972838..215ea87f93 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/container1.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/container1.php @@ -58,7 +58,7 @@ $container->loadFromExtension('security', array( ), 'access_control' => array( - array('path' => '/blog/524', 'role' => 'ROLE_USER', 'requires_channel' => 'https'), + array('path' => '/blog/524', 'role' => 'ROLE_USER', 'requires_channel' => 'https', 'methods' => array('get', 'POST')), array('path' => '/blog/.*', 'role' => 'IS_AUTHENTICATED_ANONYMOUSLY'), ), diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/container1.xml b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/container1.xml index 7dbdb5480e..210fa9b263 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/container1.xml +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/container1.xml @@ -53,7 +53,7 @@ ROLE_USER,ROLE_ADMIN,ROLE_ALLOWED_TO_SWITCH ROLE_USER,ROLE_ADMIN - + diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/container1.yml b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/container1.yml index dbfabbf5a1..544d1d1dcf 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/container1.yml +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/container1.yml @@ -49,7 +49,7 @@ security: ROLE_REMOTE: ROLE_USER,ROLE_ADMIN access_control: - - { path: /blog/524, role: ROLE_USER, requires_channel: https } + - { path: /blog/524, role: ROLE_USER, requires_channel: https, methods: [get, POST]} - path: /blog/.* role: IS_AUTHENTICATED_ANONYMOUSLY diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php index 4422a18e10..3df6784793 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php @@ -104,6 +104,7 @@ abstract class SecurityExtensionTest extends \PHPUnit_Framework_TestCase $matcherIds = array(); foreach ($rules as $rule) { list($matcherId, $roles, $channel) = $rule; + $requestMatcher = $container->getDefinition($matcherId); $this->assertFalse(isset($matcherIds[$matcherId])); $matcherIds[$matcherId] = true; @@ -112,9 +113,17 @@ abstract class SecurityExtensionTest extends \PHPUnit_Framework_TestCase if (1 === $i) { $this->assertEquals(array('ROLE_USER'), $roles); $this->assertEquals('https', $channel); + $this->assertEquals( + array('/blog/524', null, array('GET', 'POST')), + $requestMatcher->getArguments() + ); } elseif (2 === $i) { $this->assertEquals(array('IS_AUTHENTICATED_ANONYMOUSLY'), $roles); $this->assertNull($channel); + $this->assertEquals( + array('/blog/.*'), + $requestMatcher->getArguments() + ); } } } From c0675863681aab029123e9c5b7df54c4ed594c3b Mon Sep 17 00:00:00 2001 From: Vincent Simonin Date: Fri, 7 Sep 2012 17:02:54 +0200 Subject: [PATCH 03/16] [Security] Fixed digest authentication Digest authentication fail if digest parameters contains `=` character or `, ` string. --- .../Firewall/DigestAuthenticationListener.php | 11 +- .../Security/Http/Firewall/DigestDataTest.php | 110 ++++++++++++++++++ 2 files changed, 116 insertions(+), 5 deletions(-) create mode 100644 tests/Symfony/Tests/Component/Security/Http/Firewall/DigestDataTest.php diff --git a/src/Symfony/Component/Security/Http/Firewall/DigestAuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/DigestAuthenticationListener.php index 5c529dab02..8567a0005c 100644 --- a/src/Symfony/Component/Security/Http/Firewall/DigestAuthenticationListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/DigestAuthenticationListener.php @@ -141,11 +141,12 @@ class DigestData public function __construct($header) { $this->header = $header; - $parts = preg_split('/, /', $header); + preg_match_all('/(\w+)=("([^"]+)"|([^\s,$]+))/', $header, $matches, PREG_SET_ORDER); $this->elements = array(); - foreach ($parts as $part) { - list($key, $value) = explode('=', $part); - $this->elements[$key] = '"' === $value[0] ? substr($value, 1, -1) : $value; + foreach ($matches as $match) { + if (isset($match[1]) && isset($match[3])) { + $this->elements[$match[1]] = isset($match[4]) ? $match[4] : $match[3]; + } } } @@ -188,7 +189,7 @@ class DigestData $this->nonceExpiryTime = $nonceTokens[0]; if (md5($this->nonceExpiryTime.':'.$entryPointKey) !== $nonceTokens[1]) { - new BadCredentialsException(sprintf('Nonce token compromised "%s".', $nonceAsPlainText)); + throw new BadCredentialsException(sprintf('Nonce token compromised "%s".', $nonceAsPlainText)); } } diff --git a/tests/Symfony/Tests/Component/Security/Http/Firewall/DigestDataTest.php b/tests/Symfony/Tests/Component/Security/Http/Firewall/DigestDataTest.php new file mode 100644 index 0000000000..cd64f44e94 --- /dev/null +++ b/tests/Symfony/Tests/Component/Security/Http/Firewall/DigestDataTest.php @@ -0,0 +1,110 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Security\Tests\Http\Firewall; + +use Symfony\Component\Security\Http\Firewall\DigestData; + +class DigestDataTest extends \PHPUnit_Framework_TestCase +{ + public function setUp() + { + class_exists('Symfony\Component\Security\Http\Firewall\DigestAuthenticationListener', true); + } + + public function testGetResponse() + { + $digestAuth = new DigestData( + 'username="user", realm="Welcome, robot!", ' . + 'nonce="MTM0NzMyMTgyMy42NzkzOmRlZjM4NmIzOGNjMjE0OWJiNDU0MDAxNzJmYmM1MmZl", ' . + 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", ' . + 'response="b52938fc9e6d7c01be7702ece9031b42"' + ); + + $this->assertEquals('b52938fc9e6d7c01be7702ece9031b42', $digestAuth->getResponse()); + } + + public function testGetUsername() + { + $digestAuth = new DigestData( + 'username="user", realm="Welcome, robot!", ' . + 'nonce="MTM0NzMyMTgyMy42NzkzOmRlZjM4NmIzOGNjMjE0OWJiNDU0MDAxNzJmYmM1MmZl", ' . + 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", ' . + 'response="b52938fc9e6d7c01be7702ece9031b42"' + ); + + $this->assertEquals('user', $digestAuth->getUsername()); + } + + public function testValidateAndDecode() + { + $time = microtime(true); + $key = 'ThisIsAKey'; + $nonce = base64_encode($time . ':' . md5($time . ':' . $key)); + + $digestAuth = new DigestData( + 'username="user", realm="Welcome, robot!", nonce="' . $nonce . '", ' . + 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", ' . + 'response="b52938fc9e6d7c01be7702ece9031b42"' + ); + + try { + $digestAuth->validateAndDecode($key, 'Welcome, robot!'); + } catch (\Exception $e) { + $this->fail(sprintf('testValidateAndDecode fail with message: %s', $e->getMessage())); + } + } + + public function testCalculateServerDigest() + { + $username = 'user'; + $realm = 'Welcome, robot!'; + $password = 'pass,word=password'; + $time = microtime(true); + $key = 'ThisIsAKey'; + $nonce = base64_encode($time . ':' . md5($time . ':' . $key)); + $nc = '00000001'; + $cnonce = 'MDIwODkz'; + $qop = 'auth'; + $method = 'GET'; + $uri = '/path/info?p1=5&p2=5'; + + $response = md5( + md5($username . ':' . $realm . ':' . $password) . + ':' . $nonce . ':' . $nc . ':' . $cnonce . ':' . $qop . ':' . md5($method . ':' . $uri) + ); + + $digest = sprintf('username="%s", realm="%s", nonce="%s", uri="%s", cnonce="%s", nc="%s", qop="%s", response="%s"', + $username, $realm, $nonce, $uri, $cnonce, $nc, $qop, $response + ); + + $digestAuth = new DigestData($digest); + + $this->assertEquals($digestAuth->getResponse(), $digestAuth->calculateServerDigest($password, $method)); + } + + public function testIsNonceExpired() + { + $time = microtime(true) + 10; + $key = 'ThisIsAKey'; + $nonce = base64_encode($time . ':' . md5($time . ':' . $key)); + + $digestAuth = new DigestData( + 'username="user", realm="Welcome, robot!", nonce="' . $nonce . '", ' . + 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", ' . + 'response="b52938fc9e6d7c01be7702ece9031b42"' + ); + + $digestAuth->validateAndDecode($key, 'Welcome, robot!'); + + $this->assertFalse($digestAuth->isNonceExpired()); + } +} \ No newline at end of file From 694697dd915247dc29d66674bfe95161c9755ccc Mon Sep 17 00:00:00 2001 From: Vincent Simonin Date: Mon, 17 Sep 2012 17:24:25 +0200 Subject: [PATCH 04/16] [Security] Fixed digest authentication Digest authentication fail if digest parameters contains `=` character or `, ` string. * Support escaped characters --- .../Firewall/DigestAuthenticationListener.php | 2 +- .../Security/Http/Firewall/DigestDataTest.php | 36 ++++++++++++------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/Symfony/Component/Security/Http/Firewall/DigestAuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/DigestAuthenticationListener.php index 8567a0005c..b679f4d251 100644 --- a/src/Symfony/Component/Security/Http/Firewall/DigestAuthenticationListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/DigestAuthenticationListener.php @@ -141,7 +141,7 @@ class DigestData public function __construct($header) { $this->header = $header; - preg_match_all('/(\w+)=("([^"]+)"|([^\s,$]+))/', $header, $matches, PREG_SET_ORDER); + preg_match_all('/(\w+)=("((?:[^"\\\\]|\\\\.)+)"|([^\s,$]+))/', $header, $matches, PREG_SET_ORDER); $this->elements = array(); foreach ($matches as $match) { if (isset($match[1]) && isset($match[3])) { diff --git a/tests/Symfony/Tests/Component/Security/Http/Firewall/DigestDataTest.php b/tests/Symfony/Tests/Component/Security/Http/Firewall/DigestDataTest.php index cd64f44e94..df96470d3b 100644 --- a/tests/Symfony/Tests/Component/Security/Http/Firewall/DigestDataTest.php +++ b/tests/Symfony/Tests/Component/Security/Http/Firewall/DigestDataTest.php @@ -44,6 +44,18 @@ class DigestDataTest extends \PHPUnit_Framework_TestCase $this->assertEquals('user', $digestAuth->getUsername()); } + public function testGetUsernameWithQuote() + { + $digestAuth = new DigestData( + 'username="\"user\"", realm="Welcome, robot!", ' . + 'nonce="MTM0NzMyMTgyMy42NzkzOmRlZjM4NmIzOGNjMjE0OWJiNDU0MDAxNzJmYmM1MmZl", ' . + 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", ' . + 'response="b52938fc9e6d7c01be7702ece9031b42"' + ); + + $this->assertEquals('\"user\"', $digestAuth->getUsername()); + } + public function testValidateAndDecode() { $time = microtime(true); @@ -65,24 +77,24 @@ class DigestDataTest extends \PHPUnit_Framework_TestCase public function testCalculateServerDigest() { - $username = 'user'; - $realm = 'Welcome, robot!'; - $password = 'pass,word=password'; + $this->calculateServerDigest('user', 'Welcome, robot!', 'pass,word=password', 'ThisIsAKey', '00000001', 'MDIwODkz', 'auth', 'GET', '/path/info?p1=5&p2=5'); + } + + public function testCalculateServerDigestWithQuote() + { + $this->calculateServerDigest('\"user\"', 'Welcome, \"robot\"!', 'pass,word=password', 'ThisIsAKey', '00000001', 'MDIwODkz', 'auth', 'GET', '/path/info?p1=5&p2=5'); + } + + private function calculateServerDigest($username, $realm, $password, $key, $nc, $cnonce, $qop, $method, $uri) + { $time = microtime(true); - $key = 'ThisIsAKey'; $nonce = base64_encode($time . ':' . md5($time . ':' . $key)); - $nc = '00000001'; - $cnonce = 'MDIwODkz'; - $qop = 'auth'; - $method = 'GET'; - $uri = '/path/info?p1=5&p2=5'; $response = md5( - md5($username . ':' . $realm . ':' . $password) . - ':' . $nonce . ':' . $nc . ':' . $cnonce . ':' . $qop . ':' . md5($method . ':' . $uri) + md5($username . ':' . $realm . ':' . $password) . ':' . $nonce . ':' . $nc . ':' . $cnonce . ':' . $qop . ':' . md5($method . ':' . $uri) ); - $digest = sprintf('username="%s", realm="%s", nonce="%s", uri="%s", cnonce="%s", nc="%s", qop="%s", response="%s"', + $digest = sprintf('username="%s", realm="%s", nonce="%s", uri="%s", cnonce="%s", nc=%s, qop="%s", response="%s"', $username, $realm, $nonce, $uri, $cnonce, $nc, $qop, $response ); From d66b03c8308e5e9d9c654014e36a3a3b77a93745 Mon Sep 17 00:00:00 2001 From: Sebastiaan Stok Date: Sun, 28 Oct 2012 10:56:34 +0100 Subject: [PATCH 05/16] fixed CS --- .../Security/Http/Firewall/DigestDataTest.php | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/tests/Symfony/Tests/Component/Security/Http/Firewall/DigestDataTest.php b/tests/Symfony/Tests/Component/Security/Http/Firewall/DigestDataTest.php index df96470d3b..82f3215dea 100644 --- a/tests/Symfony/Tests/Component/Security/Http/Firewall/DigestDataTest.php +++ b/tests/Symfony/Tests/Component/Security/Http/Firewall/DigestDataTest.php @@ -15,11 +15,6 @@ use Symfony\Component\Security\Http\Firewall\DigestData; class DigestDataTest extends \PHPUnit_Framework_TestCase { - public function setUp() - { - class_exists('Symfony\Component\Security\Http\Firewall\DigestAuthenticationListener', true); - } - public function testGetResponse() { $digestAuth = new DigestData( @@ -85,6 +80,28 @@ class DigestDataTest extends \PHPUnit_Framework_TestCase $this->calculateServerDigest('\"user\"', 'Welcome, \"robot\"!', 'pass,word=password', 'ThisIsAKey', '00000001', 'MDIwODkz', 'auth', 'GET', '/path/info?p1=5&p2=5'); } + public function testIsNonceExpired() + { + $time = microtime(true) + 10; + $key = 'ThisIsAKey'; + $nonce = base64_encode($time . ':' . md5($time . ':' . $key)); + + $digestAuth = new DigestData( + 'username="user", realm="Welcome, robot!", nonce="' . $nonce . '", ' . + 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", ' . + 'response="b52938fc9e6d7c01be7702ece9031b42"' + ); + + $digestAuth->validateAndDecode($key, 'Welcome, robot!'); + + $this->assertFalse($digestAuth->isNonceExpired()); + } + + protected function setUp() + { + class_exists('Symfony\Component\Security\Http\Firewall\DigestAuthenticationListener', true); + } + private function calculateServerDigest($username, $realm, $password, $key, $nc, $cnonce, $qop, $method, $uri) { $time = microtime(true); @@ -102,21 +119,4 @@ class DigestDataTest extends \PHPUnit_Framework_TestCase $this->assertEquals($digestAuth->getResponse(), $digestAuth->calculateServerDigest($password, $method)); } - - public function testIsNonceExpired() - { - $time = microtime(true) + 10; - $key = 'ThisIsAKey'; - $nonce = base64_encode($time . ':' . md5($time . ':' . $key)); - - $digestAuth = new DigestData( - 'username="user", realm="Welcome, robot!", nonce="' . $nonce . '", ' . - 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", ' . - 'response="b52938fc9e6d7c01be7702ece9031b42"' - ); - - $digestAuth->validateAndDecode($key, 'Welcome, robot!'); - - $this->assertFalse($digestAuth->isNonceExpired()); - } -} \ No newline at end of file +} From 80f6992a4146472211fc72fb348f966b91a6d3e8 Mon Sep 17 00:00:00 2001 From: Sebastiaan Stok Date: Sun, 28 Oct 2012 11:58:35 +0100 Subject: [PATCH 06/16] [Security] added test extra for digest authentication --- .../Security/Http/Firewall/DigestDataTest.php | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/tests/Symfony/Tests/Component/Security/Http/Firewall/DigestDataTest.php b/tests/Symfony/Tests/Component/Security/Http/Firewall/DigestDataTest.php index 82f3215dea..d201c8f6df 100644 --- a/tests/Symfony/Tests/Component/Security/Http/Firewall/DigestDataTest.php +++ b/tests/Symfony/Tests/Component/Security/Http/Firewall/DigestDataTest.php @@ -51,6 +51,42 @@ class DigestDataTest extends \PHPUnit_Framework_TestCase $this->assertEquals('\"user\"', $digestAuth->getUsername()); } + public function testGetUsernameWithQuoteAndEscape() + { + $digestAuth = new DigestData( + 'username="\"u\\\\\"ser\"", realm="Welcome, robot!", ' . + 'nonce="MTM0NzMyMTgyMy42NzkzOmRlZjM4NmIzOGNjMjE0OWJiNDU0MDAxNzJmYmM1MmZl", ' . + 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", ' . + 'response="b52938fc9e6d7c01be7702ece9031b42"' + ); + + $this->assertEquals('\"u\\\\\"ser\"', $digestAuth->getUsername()); + } + + public function testGetUsernameWithSingleQuote() + { + $digestAuth = new DigestData( + 'username="\"u\'ser\"", realm="Welcome, robot!", ' . + 'nonce="MTM0NzMyMTgyMy42NzkzOmRlZjM4NmIzOGNjMjE0OWJiNDU0MDAxNzJmYmM1MmZl", ' . + 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", ' . + 'response="b52938fc9e6d7c01be7702ece9031b42"' + ); + + $this->assertEquals('\"u\'ser\"', $digestAuth->getUsername()); + } + + public function testGetUsernameWithEscape() + { + $digestAuth = new DigestData( + 'username="\"u\\ser\"", realm="Welcome, robot!", ' . + 'nonce="MTM0NzMyMTgyMy42NzkzOmRlZjM4NmIzOGNjMjE0OWJiNDU0MDAxNzJmYmM1MmZl", ' . + 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", ' . + 'response="b52938fc9e6d7c01be7702ece9031b42"' + ); + + $this->assertEquals('\"u\\ser\"', $digestAuth->getUsername()); + } + public function testValidateAndDecode() { $time = microtime(true); @@ -80,6 +116,17 @@ class DigestDataTest extends \PHPUnit_Framework_TestCase $this->calculateServerDigest('\"user\"', 'Welcome, \"robot\"!', 'pass,word=password', 'ThisIsAKey', '00000001', 'MDIwODkz', 'auth', 'GET', '/path/info?p1=5&p2=5'); } + public function testCalculateServerDigestWithQuoteAndEscape() + { + $this->calculateServerDigest('\"u\\\\\"ser\"', 'Welcome, \"robot\"!', 'pass,word=password', 'ThisIsAKey', '00000001', 'MDIwODkz', 'auth', 'GET', '/path/info?p1=5&p2=5'); + } + + public function testCalculateServerDigestEscape() + { + $this->calculateServerDigest('\"u\\ser\"', 'Welcome, \"robot\"!', 'pass,word=password', 'ThisIsAKey', '00000001', 'MDIwODkz', 'auth', 'GET', '/path/info?p1=5&p2=5'); + $this->calculateServerDigest('\"u\\ser\\\\\"', 'Welcome, \"robot\"!', 'pass,word=password', 'ThisIsAKey', '00000001', 'MDIwODkz', 'auth', 'GET', '/path/info?p1=5&p2=5'); + } + public function testIsNonceExpired() { $time = microtime(true) + 10; From f2cbea3b309c52951267f5f05b3842cf1b502dd4 Mon Sep 17 00:00:00 2001 From: Sebastiaan Stok Date: Thu, 15 Nov 2012 16:54:04 +0100 Subject: [PATCH 07/16] [Security] remove escape charters from username provided by Digest DigestAuthenticationListener --- .../Firewall/DigestAuthenticationListener.php | 2 +- .../Security/Http/Firewall/DigestDataTest.php | 20 +++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Component/Security/Http/Firewall/DigestAuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/DigestAuthenticationListener.php index b679f4d251..2bc4aa550f 100644 --- a/src/Symfony/Component/Security/Http/Firewall/DigestAuthenticationListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/DigestAuthenticationListener.php @@ -157,7 +157,7 @@ class DigestData public function getUsername() { - return $this->elements['username']; + return strtr($this->elements['username'], array("\\\"" => "\"", "\\\\" => "\\")); } public function validateAndDecode($entryPointKey, $expectedRealm) diff --git a/tests/Symfony/Tests/Component/Security/Http/Firewall/DigestDataTest.php b/tests/Symfony/Tests/Component/Security/Http/Firewall/DigestDataTest.php index d201c8f6df..cfb929cacc 100644 --- a/tests/Symfony/Tests/Component/Security/Http/Firewall/DigestDataTest.php +++ b/tests/Symfony/Tests/Component/Security/Http/Firewall/DigestDataTest.php @@ -48,7 +48,7 @@ class DigestDataTest extends \PHPUnit_Framework_TestCase 'response="b52938fc9e6d7c01be7702ece9031b42"' ); - $this->assertEquals('\"user\"', $digestAuth->getUsername()); + $this->assertEquals('"user"', $digestAuth->getUsername()); } public function testGetUsernameWithQuoteAndEscape() @@ -60,7 +60,7 @@ class DigestDataTest extends \PHPUnit_Framework_TestCase 'response="b52938fc9e6d7c01be7702ece9031b42"' ); - $this->assertEquals('\"u\\\\\"ser\"', $digestAuth->getUsername()); + $this->assertEquals('"u\\"ser"', $digestAuth->getUsername()); } public function testGetUsernameWithSingleQuote() @@ -72,7 +72,19 @@ class DigestDataTest extends \PHPUnit_Framework_TestCase 'response="b52938fc9e6d7c01be7702ece9031b42"' ); - $this->assertEquals('\"u\'ser\"', $digestAuth->getUsername()); + $this->assertEquals('"u\'ser"', $digestAuth->getUsername()); + } + + public function testGetUsernameWithSingleQuoteAndEscape() + { + $digestAuth = new DigestData( + 'username="\"u\\\'ser\"", realm="Welcome, robot!", ' . + 'nonce="MTM0NzMyMTgyMy42NzkzOmRlZjM4NmIzOGNjMjE0OWJiNDU0MDAxNzJmYmM1MmZl", ' . + 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", ' . + 'response="b52938fc9e6d7c01be7702ece9031b42"' + ); + + $this->assertEquals('"u\\\'ser"', $digestAuth->getUsername()); } public function testGetUsernameWithEscape() @@ -84,7 +96,7 @@ class DigestDataTest extends \PHPUnit_Framework_TestCase 'response="b52938fc9e6d7c01be7702ece9031b42"' ); - $this->assertEquals('\"u\\ser\"', $digestAuth->getUsername()); + $this->assertEquals('"u\\ser"', $digestAuth->getUsername()); } public function testValidateAndDecode() From b0e468f9ba8e253a4cc6721d79132f9cc35b9e0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Bourgeois?= Date: Wed, 14 Nov 2012 23:12:43 +0100 Subject: [PATCH 08/16] Update src/Symfony/Component/DomCrawler/Form.php --- src/Symfony/Component/DomCrawler/Form.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/DomCrawler/Form.php b/src/Symfony/Component/DomCrawler/Form.php index ad046c03dc..6f33c0fb51 100644 --- a/src/Symfony/Component/DomCrawler/Form.php +++ b/src/Symfony/Component/DomCrawler/Form.php @@ -294,7 +294,7 @@ class Form extends Link implements \ArrayAccess $xpath = new \DOMXPath($document); foreach ($xpath->query('descendant::input | descendant::button | descendant::textarea | descendant::select', $root) as $node) { - if (!$node->hasAttribute('name')) { + if (!$node->hasAttribute('name') || !$node->getAttribute('name')) { continue; } From e7401a21296cfada35db395cad8aeadc4723fb3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Bourgeois?= Date: Thu, 15 Nov 2012 10:18:26 +0100 Subject: [PATCH 09/16] Update src/Symfony/Component/DomCrawler/Tests/FormTest.php --- tests/Symfony/Tests/Component/DomCrawler/FormTest.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/Symfony/Tests/Component/DomCrawler/FormTest.php b/tests/Symfony/Tests/Component/DomCrawler/FormTest.php index 41e599ec66..8250f2c2e3 100644 --- a/tests/Symfony/Tests/Component/DomCrawler/FormTest.php +++ b/tests/Symfony/Tests/Component/DomCrawler/FormTest.php @@ -72,6 +72,12 @@ class FormTest extends \PHPUnit_Framework_TestCase ', array(), ), + array( + 'does not take into account input fields with an empty name attribute value', + ' + ', + array(), + ), array( 'takes into account disabled input fields', ' From 64216f25a5f16d0bdb15614cab25bbf2a78381dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Flode=CC=81n?= Date: Mon, 19 Nov 2012 20:04:16 +0100 Subject: [PATCH 10/16] Add tests for urlRedirectAction --- .../Controller/RedirectControllerTest.php | 127 ++++++++++++++++++ 1 file changed, 127 insertions(+) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php index d8d5df67cc..77af9ae361 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php @@ -109,4 +109,131 @@ class RedirectControllerTest extends TestCase $this->assertEquals('http://foo.bar/', $returnResponse->headers->get('Location')); $this->assertEquals(302, $returnResponse->getStatusCode()); } + + public function testUrlRedirectDefaultPortParameters() + { + $host = 'www.example.com'; + $baseUrl = '/base'; + $path = '/redirect-path'; + $httpPort = 1080; + $httpsPort = 1443; + + $expectedUrl = "https://$host:$httpsPort$baseUrl$path"; + $request = $this->createRequestObject('http', $host, $httpPort, $baseUrl); + $controller = $this->createRedirectController($request, null, $httpsPort); + $returnValue = $controller->urlRedirectAction($path, false, 'https'); + $this->assertRedirectUrl($returnValue, $expectedUrl); + + $expectedUrl = "http://$host:$httpPort$baseUrl$path"; + $request = $this->createRequestObject('https', $host, $httpPort, $baseUrl); + $controller = $this->createRedirectController($request, $httpPort); + $returnValue = $controller->urlRedirectAction($path, false, 'http'); + $this->assertRedirectUrl($returnValue, $expectedUrl); + } + + public function urlRedirectProvider() + { + return array( + // Standard ports + array('http', null, null, 'http', 80, ""), + array('http', 80, null, 'http', 80, ""), + array('https', null, null, 'http', 80, ""), + array('https', 80, null, 'http', 80, ""), + + array('http', null, null, 'https', 443, ""), + array('http', null, 443, 'https', 443, ""), + array('https', null, null, 'https', 443, ""), + array('https', null, 443, 'https', 443, ""), + + // Non-standard ports + array('http', null, null, 'http', 8080, ":8080"), + array('http', 4080, null, 'http', 8080, ":4080"), + array('http', 80, null, 'http', 8080, ""), + array('https', null, null, 'http', 8080, ""), + array('https', null, 8443, 'http', 8080, ":8443"), + array('https', null, 443, 'http', 8080, ""), + + array('https', null, null, 'https', 8443, ":8443"), + array('https', null, 4443, 'https', 8443, ":4443"), + array('https', null, 443, 'https', 8443, ""), + array('http', null, null, 'https', 8443, ""), + array('http', 8080, 4443, 'https', 8443, ":8080"), + array('http', 80, 4443, 'https', 8443, ""), + ); + } + + /** + * @dataProvider urlRedirectProvider + */ + public function testUrlRedirect($scheme, $httpPort, $httpsPort, $requestScheme, $requestPort, $expectedPort) + { + $host = 'www.example.com'; + $baseUrl = '/base'; + $path = '/redirect-path'; + $expectedUrl = "$scheme://$host$expectedPort$baseUrl$path"; + + $request = $this->createRequestObject($requestScheme, $host, $requestPort, $baseUrl); + $controller = $this->createRedirectController($request); + + $returnValue = $controller->urlRedirectAction($path, false, $scheme, $httpPort, $httpsPort); + $this->assertRedirectUrl($returnValue, $expectedUrl); + } + + public function createRequestObject($scheme, $host, $port, $baseUrl) + { + $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); + $request + ->expects($this->any()) + ->method('getScheme') + ->will($this->returnValue($scheme)); + $request + ->expects($this->any()) + ->method('getHost') + ->will($this->returnValue($host)); + $request + ->expects($this->any()) + ->method('getPort') + ->will($this->returnValue($port)); + $request + ->expects($this->any()) + ->method('getBaseUrl') + ->will($this->returnValue($baseUrl)); + + return $request; + } + + public function createRedirectController($request, $httpPort = null, $httpsPort = null) + { + $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + $container + ->expects($this->at(0)) + ->method('get') + ->with($this->equalTo('request')) + ->will($this->returnValue($request)); + if ($httpPort != null) { + $container + ->expects($this->at(1)) + ->method('getParameter') + ->with($this->equalTo('request_listener.http_port')) + ->will($this->returnValue($httpPort)); + } + if ($httpsPort != null) { + $container + ->expects($this->at(1)) + ->method('getParameter') + ->with($this->equalTo('request_listener.https_port')) + ->will($this->returnValue($httpsPort)); + } + + $controller = new RedirectController(); + $controller->setContainer($container); + + return $controller; + } + + public function assertRedirectUrl($returnValue, $expectedUrl) + { + $this->assertTrue($returnValue->isRedirect($expectedUrl), + "Expected: $expectedUrl\nGot: " . $returnValue->headers->get('Location')); + } } From 64b54dc587981971c17d8a1a45fe35fdbe3426a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Flode=CC=81n?= Date: Mon, 19 Nov 2012 20:08:12 +0100 Subject: [PATCH 11/16] Use better default ports in urlRedirectAction --- .../Controller/RedirectController.php | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php b/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php index 10d0a90a70..ea76b19e7e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php @@ -64,7 +64,7 @@ class RedirectController extends ContainerAware * * @return Response A Response instance */ - public function urlRedirectAction($path, $permanent = false, $scheme = null, $httpPort = 80, $httpsPort = 443) + public function urlRedirectAction($path, $permanent = false, $scheme = null, $httpPort = null, $httpsPort = null) { if (!$path) { return new Response(null, 410); @@ -88,10 +88,28 @@ class RedirectController extends ContainerAware } $port = ''; - if ('http' === $scheme && 80 != $httpPort) { - $port = ':'.$httpPort; - } elseif ('https' === $scheme && 443 != $httpsPort) { - $port = ':'.$httpsPort; + if ('http' === $scheme) { + if ($httpPort == null) { + if ('http' === $request->getScheme()) { + $httpPort = $request->getPort(); + } else { + $httpPort = $this->container->getParameter('request_listener.http_port'); + } + } + if ($httpPort != null && $httpPort != 80) { + $port = ":$httpPort"; + } + } else if ('https' === $scheme) { + if ($httpsPort == null) { + if ('https' === $request->getScheme()) { + $httpsPort = $request->getPort(); + } else { + $httpsPort = $this->container->getParameter('request_listener.https_port'); + } + } + if ($httpsPort != null && $httpsPort != 443) { + $port = ":$httpsPort"; + } } $url = $scheme.'://'.$request->getHost().$port.$request->getBaseUrl().$path.$qs; From 85be887e594fdfa79808c170514689466d2304b2 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 19 Nov 2012 21:00:36 +0100 Subject: [PATCH 12/16] fixed CS --- .../Bundle/FrameworkBundle/Controller/RedirectController.php | 4 +++- .../Tests/Controller/RedirectControllerTest.php | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php b/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php index ea76b19e7e..174dc473d5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php @@ -96,10 +96,11 @@ class RedirectController extends ContainerAware $httpPort = $this->container->getParameter('request_listener.http_port'); } } + if ($httpPort != null && $httpPort != 80) { $port = ":$httpPort"; } - } else if ('https' === $scheme) { + } elseif ('https' === $scheme) { if ($httpsPort == null) { if ('https' === $request->getScheme()) { $httpsPort = $request->getPort(); @@ -107,6 +108,7 @@ class RedirectController extends ContainerAware $httpsPort = $this->container->getParameter('request_listener.https_port'); } } + if ($httpsPort != null && $httpsPort != 443) { $port = ":$httpsPort"; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php index 77af9ae361..b4f6f0f023 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php @@ -233,7 +233,6 @@ class RedirectControllerTest extends TestCase public function assertRedirectUrl($returnValue, $expectedUrl) { - $this->assertTrue($returnValue->isRedirect($expectedUrl), - "Expected: $expectedUrl\nGot: " . $returnValue->headers->get('Location')); + $this->assertTrue($returnValue->isRedirect($expectedUrl), "Expected: $expectedUrl\nGot: ".$returnValue->headers->get('Location')); } } From 29bfa13ff0c217d59e34d4915033a8ed65bdd3e8 Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Mon, 19 Nov 2012 21:41:59 +0100 Subject: [PATCH 13/16] small fix of #5984 when the container param is not set this can happen when the config for the router is unset, but this method does not need to depend on routing. reading an unset config would raise an exception. --- .../Controller/RedirectController.php | 28 +++++++-------- .../Controller/RedirectControllerTest.php | 34 +++++++++++-------- 2 files changed, 33 insertions(+), 29 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php b/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php index 174dc473d5..842a08b11a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php @@ -28,7 +28,7 @@ class RedirectController extends ContainerAware * It expects a route path parameter. * By default, the response status code is 301. * - * If the route empty, the status code will be 410. + * If the route is empty, the status code will be 410. * If the permanent path parameter is set, the status code will be 302. * * @param string $route The route pattern to redirect to @@ -56,11 +56,11 @@ class RedirectController extends ContainerAware * If the path is empty, the status code will be 410. * If the permanent flag is set, the status code will be 302. * - * @param string $path The path to redirect to - * @param Boolean $permanent Whether the redirect is permanent or not - * @param Boolean $scheme The URL scheme (null to keep the current one) - * @param integer $httpPort The HTTP port - * @param integer $httpsPort The HTTPS port + * @param string $path The path to redirect to + * @param Boolean $permanent Whether the redirect is permanent or not + * @param string|null $scheme The URL scheme (null to keep the current one) + * @param integer|null $httpPort The HTTP port (null to keep the current one for the same scheme or the configured port in the container) + * @param integer|null $httpsPort The HTTPS port (null to keep the current one for the same scheme or the configured port in the container) * * @return Response A Response instance */ @@ -89,27 +89,25 @@ class RedirectController extends ContainerAware $port = ''; if ('http' === $scheme) { - if ($httpPort == null) { + if (null === $httpPort) { if ('http' === $request->getScheme()) { $httpPort = $request->getPort(); - } else { + } elseif ($this->container->hasParameter('request_listener.http_port')) { $httpPort = $this->container->getParameter('request_listener.http_port'); } } - - if ($httpPort != null && $httpPort != 80) { + if (null !== $httpPort && 80 != $httpPort) { $port = ":$httpPort"; } } elseif ('https' === $scheme) { - if ($httpsPort == null) { + if (null === $httpsPort) { if ('https' === $request->getScheme()) { $httpsPort = $request->getPort(); - } else { + } elseif ($this->container->hasParameter('request_listener.https_port')) { $httpsPort = $this->container->getParameter('request_listener.https_port'); - } + }; } - - if ($httpsPort != null && $httpsPort != 443) { + if (null !== $httpsPort && 443 != $httpsPort) { $port = ":$httpsPort"; } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php index b4f6f0f023..984810bd9b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php @@ -75,9 +75,7 @@ class RedirectControllerTest extends TestCase $returnResponse = $controller->redirectAction($route, $permanent); - $this->assertInstanceOf('\Symfony\Component\HttpFoundation\Response', $returnResponse); - - $this->assertTrue($returnResponse->isRedirect($url)); + $this->assertRedirectUrl($returnResponse, $url); $this->assertEquals($expectedCode, $returnResponse->getStatusCode()); } @@ -104,9 +102,7 @@ class RedirectControllerTest extends TestCase $controller = new RedirectController(); $returnResponse = $controller->urlRedirectAction('http://foo.bar/'); - $this->assertInstanceOf('\Symfony\Component\HttpFoundation\Response', $returnResponse); - - $this->assertEquals('http://foo.bar/', $returnResponse->headers->get('Location')); + $this->assertRedirectUrl($returnResponse, 'http://foo.bar/'); $this->assertEquals(302, $returnResponse->getStatusCode()); } @@ -179,7 +175,7 @@ class RedirectControllerTest extends TestCase $this->assertRedirectUrl($returnValue, $expectedUrl); } - public function createRequestObject($scheme, $host, $port, $baseUrl) + private function createRequestObject($scheme, $host, $port, $baseUrl) { $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); $request @@ -202,7 +198,7 @@ class RedirectControllerTest extends TestCase return $request; } - public function createRedirectController($request, $httpPort = null, $httpsPort = null) + private function createRedirectController(Request $request, $httpPort = null, $httpsPort = null) { $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); $container @@ -210,16 +206,26 @@ class RedirectControllerTest extends TestCase ->method('get') ->with($this->equalTo('request')) ->will($this->returnValue($request)); - if ($httpPort != null) { + if (null !== $httpPort) { $container - ->expects($this->at(1)) + ->expects($this->once()) + ->method('hasParameter') + ->with($this->equalTo('request_listener.http_port')) + ->will($this->returnValue(true)); + $container + ->expects($this->once()) ->method('getParameter') ->with($this->equalTo('request_listener.http_port')) ->will($this->returnValue($httpPort)); } - if ($httpsPort != null) { + if (null !== $httpsPort) { $container - ->expects($this->at(1)) + ->expects($this->once()) + ->method('hasParameter') + ->with($this->equalTo('request_listener.https_port')) + ->will($this->returnValue(true)); + $container + ->expects($this->once()) ->method('getParameter') ->with($this->equalTo('request_listener.https_port')) ->will($this->returnValue($httpsPort)); @@ -231,8 +237,8 @@ class RedirectControllerTest extends TestCase return $controller; } - public function assertRedirectUrl($returnValue, $expectedUrl) + public function assertRedirectUrl(Response $returnResponse, $expectedUrl) { - $this->assertTrue($returnValue->isRedirect($expectedUrl), "Expected: $expectedUrl\nGot: ".$returnValue->headers->get('Location')); + $this->assertTrue($returnResponse->isRedirect($expectedUrl), "Expected: $expectedUrl\nGot: ".$returnResponse->headers->get('Location')); } } From c20efc7c78a0b8336a0179c0365e2159313106da Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 24 Nov 2012 12:10:50 +0100 Subject: [PATCH 14/16] fixed CS --- .../Bundle/FrameworkBundle/Controller/RedirectController.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php b/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php index 842a08b11a..5598770235 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php @@ -96,6 +96,7 @@ class RedirectController extends ContainerAware $httpPort = $this->container->getParameter('request_listener.http_port'); } } + if (null !== $httpPort && 80 != $httpPort) { $port = ":$httpPort"; } @@ -105,8 +106,9 @@ class RedirectController extends ContainerAware $httpsPort = $request->getPort(); } elseif ($this->container->hasParameter('request_listener.https_port')) { $httpsPort = $this->container->getParameter('request_listener.https_port'); - }; + } } + if (null !== $httpsPort && 443 != $httpsPort) { $port = ":$httpsPort"; } From ac77c5b2d8d4d448e8408c5889a25f2ca659b7c1 Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Sat, 24 Nov 2012 14:53:14 +0100 Subject: [PATCH 15/16] [Form] Updated checks for the ICU version from 4.5+ to 4.7+ due to test failures with ICU 4.6 --- ...NumberToLocalizedStringTransformerTest.php | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/Symfony/Tests/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php b/tests/Symfony/Tests/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php index 33d2952a6c..06905c68c5 100644 --- a/tests/Symfony/Tests/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php +++ b/tests/Symfony/Tests/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php @@ -98,8 +98,8 @@ class NumberToLocalizedStringTransformerTest extends LocalizedTestCase public function testDecimalSeparatorMayBeDotIfGroupingSeparatorIsNotDot() { - if ($this->isLowerThanIcuVersion('4.5')) { - $this->markTestSkipped('Please upgrade ICU version to 4.5+'); + if ($this->isLowerThanIcuVersion('4.7')) { + $this->markTestSkipped('Please upgrade ICU version to 4.7+'); } \Locale::setDefault('fr'); @@ -119,8 +119,8 @@ class NumberToLocalizedStringTransformerTest extends LocalizedTestCase */ public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDot() { - if ($this->isLowerThanIcuVersion('4.5')) { - $this->markTestSkipped('Please upgrade ICU version to 4.5+'); + if ($this->isLowerThanIcuVersion('4.7')) { + $this->markTestSkipped('Please upgrade ICU version to 4.7+'); } $transformer = new NumberToLocalizedStringTransformer(null, true); @@ -133,8 +133,8 @@ class NumberToLocalizedStringTransformerTest extends LocalizedTestCase */ public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDot_noGroupSep() { - if ($this->isLowerThanIcuVersion('4.5')) { - $this->markTestSkipped('Please upgrade ICU version to 4.5+'); + if ($this->isLowerThanIcuVersion('4.7')) { + $this->markTestSkipped('Please upgrade ICU version to 4.7+'); } $transformer = new NumberToLocalizedStringTransformer(null, true); @@ -153,8 +153,8 @@ class NumberToLocalizedStringTransformerTest extends LocalizedTestCase public function testDecimalSeparatorMayBeCommaIfGroupingSeparatorIsNotComma() { - if ($this->isLowerThanIcuVersion('4.5')) { - $this->markTestSkipped('Please upgrade ICU version to 4.5+'); + if ($this->isLowerThanIcuVersion('4.7')) { + $this->markTestSkipped('Please upgrade ICU version to 4.7+'); } \Locale::setDefault('ak'); @@ -174,8 +174,8 @@ class NumberToLocalizedStringTransformerTest extends LocalizedTestCase */ public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsComma() { - if ($this->isLowerThanIcuVersion('4.5')) { - $this->markTestSkipped('Please upgrade ICU version to 4.5+'); + if ($this->isLowerThanIcuVersion('4.7')) { + $this->markTestSkipped('Please upgrade ICU version to 4.7+'); } \Locale::setDefault('en'); @@ -189,8 +189,8 @@ class NumberToLocalizedStringTransformerTest extends LocalizedTestCase */ public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsComma_noGroupSep() { - if ($this->isLowerThanIcuVersion('4.5')) { - $this->markTestSkipped('Please upgrade ICU version to 4.5+'); + if ($this->isLowerThanIcuVersion('4.7')) { + $this->markTestSkipped('Please upgrade ICU version to 4.7+'); } \Locale::setDefault('en'); From fc89d6b643ceeb024765ce1581d065619220925b Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 27 Nov 2012 09:54:37 +0100 Subject: [PATCH 16/16] [DependencyInjection] fixed composer.json --- src/Symfony/Component/DependencyInjection/composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/DependencyInjection/composer.json b/src/Symfony/Component/DependencyInjection/composer.json index 6824a8f4fb..676c5c312b 100644 --- a/src/Symfony/Component/DependencyInjection/composer.json +++ b/src/Symfony/Component/DependencyInjection/composer.json @@ -19,7 +19,7 @@ "php": ">=5.3.2" }, "suggest": { - "symfony/config": "self.version" + "symfony/config": "self.version", "symfony/yaml": "self.version" }, "autoload": {