Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f971f4f

Browse files
committed
Merge branch '2.7' into 2.8
* 2.7: removed test that does not test anything fixed tests #21809 [SecurityBundle] bugfix: if security provider's name contains upper cases then container didn't compile [Validator] fix URL validator to detect non supported chars according to RFC 3986 [Security] Fixed roles serialization on token from user object
2 parents f354a47 + 80af083 commit f971f4f

File tree

6 files changed

+27
-7
lines changed

6 files changed

+27
-7
lines changed

src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ private function createUserProviders($config, ContainerBuilder $container)
513513
// Parses a <provider> tag and returns the id for the related user provider service
514514
private function createUserDaoProvider($name, $provider, ContainerBuilder $container)
515515
{
516-
$name = $this->getUserProviderId(strtolower($name));
516+
$name = $this->getUserProviderId($name);
517517

518518
// Doctrine Entity and In-memory DAO provider are managed by factories
519519
foreach ($this->userProviderFactories as $factory) {
@@ -537,7 +537,7 @@ private function createUserDaoProvider($name, $provider, ContainerBuilder $conta
537537
if (isset($provider['chain'])) {
538538
$providers = array();
539539
foreach ($provider['chain']['providers'] as $providerName) {
540-
$providers[] = new Reference($this->getUserProviderId(strtolower($providerName)));
540+
$providers[] = new Reference($this->getUserProviderId($providerName));
541541
}
542542

543543
$container
@@ -552,7 +552,7 @@ private function createUserDaoProvider($name, $provider, ContainerBuilder $conta
552552

553553
private function getUserProviderId($name)
554554
{
555-
return 'security.user.provider.concrete.'.$name;
555+
return 'security.user.provider.concrete.'.strtolower($name);
556556
}
557557

558558
private function createExceptionListener($container, $config, $id, $defaultEntryPoint, $stateless)

src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public function serialize()
150150
array(
151151
is_object($this->user) ? clone $this->user : $this->user,
152152
$this->authenticated,
153-
$this->roles,
153+
array_map(function ($role) { return clone $role; }, $this->roles),
154154
$this->attributes,
155155
)
156156
);

src/Symfony/Component/Security/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ public function testAuthenticateWithPreservingRoleSwitchUserRole()
221221
$this->assertInstanceOf('Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken', $authToken);
222222
$this->assertSame($user, $authToken->getUser());
223223
$this->assertContains(new Role('ROLE_FOO'), $authToken->getRoles(), '', false, false);
224-
$this->assertContains($switchUserRole, $authToken->getRoles());
224+
$this->assertContains($switchUserRole, $authToken->getRoles(), '', false, false);
225225
$this->assertEquals('foo', $authToken->getCredentials());
226226
$this->assertEquals(array('foo' => 'bar'), $authToken->getAttributes(), '->authenticate() copies token attributes');
227227
}

src/Symfony/Component/Security/Core/Tests/Authentication/Token/AbstractTokenTest.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\Security\Core\Authentication\Token\AbstractToken;
1616
use Symfony\Component\Security\Core\Role\Role;
1717
use Symfony\Component\Security\Core\Role\SwitchUserRole;
18+
use Symfony\Component\Security\Core\User\User;
1819

1920
class TestUser
2021
{
@@ -89,7 +90,7 @@ public function testEraseCredentials()
8990

9091
public function testSerialize()
9192
{
92-
$token = $this->getToken(array('ROLE_FOO'));
93+
$token = $this->getToken(array('ROLE_FOO', new Role('ROLE_BAR')));
9394
$token->setAttributes(array('foo' => 'bar'));
9495

9596
$uToken = unserialize(serialize($token));
@@ -98,6 +99,19 @@ public function testSerialize()
9899
$this->assertEquals($token->getAttributes(), $uToken->getAttributes());
99100
}
100101

102+
public function testSerializeWithRoleObjects()
103+
{
104+
$user = new User('name', 'password', array(new Role('ROLE_FOO'), new Role('ROLE_BAR')));
105+
$token = new ConcreteToken($user, $user->getRoles());
106+
107+
$serialized = serialize($token);
108+
$unserialized = unserialize($serialized);
109+
110+
$roles = $unserialized->getRoles();
111+
112+
$this->assertEquals($roles, $user->getRoles());
113+
}
114+
101115
public function testSerializeParent()
102116
{
103117
$user = new TestUser('fabien');

src/Symfony/Component/Validator/Constraints/UrlValidator.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ class UrlValidator extends ConstraintValidator
3434
\] # an IPv6 address
3535
)
3636
(:[0-9]+)? # a port (optional)
37-
(/?|/\S+|\?\S*|\#\S*) # a /, nothing, a / with something, a query or a fragment
37+
(?:/ (?:[\pL\pN\-._\~!$&\'()*+,;=:@]|%%[0-9A-Fa-f]{2})* )* # a path
38+
(?:\? (?:[\pL\pN\-._\~!$&\'()*+,;=:@/?]|%%[0-9A-Fa-f]{2})* )? # a query (optional)
39+
(?:\# (?:[\pL\pN\-._\~!$&\'()*+,;=:@/?]|%%[0-9A-Fa-f]{2})* )? # a fragment (optional)
3840
$~ixu';
3941

4042
/**

src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ public function getValidUrls()
128128
array('http://symfony.com#'),
129129
array('http://symfony.com#fragment'),
130130
array('http://symfony.com/#fragment'),
131+
array('http://symfony.com/#one_more%20test'),
131132
);
132133
}
133134

@@ -168,6 +169,9 @@ public function getInvalidUrls()
168169
array('http://:password@@symfony.com'),
169170
array('http://username:passwordsymfony.com'),
170171
array('http://usern@me:[email protected]'),
172+
array('http://example.com/exploit.html?<script>alert(1);</script>'),
173+
array('http://example.com/exploit.html?hel lo'),
174+
array('http://example.com/exploit.html?not_a%hex'),
171175
);
172176
}
173177

0 commit comments

Comments
 (0)