Skip to content

Commit fb56bcc

Browse files
committed
Merge branch '2.8' into 3.2
* 2.8: 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 [WebProfilerBundle] Fix for CSS attribute at Profiler Translation Page Set Date header in Response constructor already [Validator] fix URL validator to detect non supported chars according to RFC 3986 [Security] Fixed roles serialization on token from user object
2 parents f296648 + f971f4f commit fb56bcc

File tree

10 files changed

+47
-11
lines changed

10 files changed

+47
-11
lines changed

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

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

559559
// Doctrine Entity and In-memory DAO provider are managed by factories
560560
foreach ($this->userProviderFactories as $factory) {
@@ -578,7 +578,7 @@ private function createUserDaoProvider($name, $provider, ContainerBuilder $conta
578578
if (isset($provider['chain'])) {
579579
$providers = array();
580580
foreach ($provider['chain']['providers'] as $providerName) {
581-
$providers[] = new Reference($this->getUserProviderId(strtolower($providerName)));
581+
$providers[] = new Reference($this->getUserProviderId($providerName));
582582
}
583583

584584
$container
@@ -593,7 +593,7 @@ private function createUserDaoProvider($name, $provider, ContainerBuilder $conta
593593

594594
private function getUserProviderId($name)
595595
{
596-
return 'security.user.provider.concrete.'.$name;
596+
return 'security.user.provider.concrete.'.strtolower($name);
597597
}
598598

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

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/translation.html.twig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,10 @@
169169
{% for message in messages %}
170170
<tr>
171171
<td class="font-normal text-small">{{ message.locale }}</td>
172-
<td class="font-normal text-small text-bold">{{ message.domain }}</td>
172+
<td class="font-normal text-small text-bold nowrap">{{ message.domain }}</td>
173173
<td class="font-normal text-small">{{ message.count }}</td>
174174
<td>
175-
{{ message.id }}
175+
<span class="nowrap">{{ message.id }}</span>
176176

177177
{% if message.transChoiceNumber is not null %}
178178
<small class="newline">(pluralization is used)</small>
@@ -188,7 +188,7 @@
188188
</div>
189189
{% endif %}
190190
</td>
191-
<td>{{ message.translation }}</td>
191+
<td class="prewrap">{{ message.translation }}</td>
192192
</tr>
193193
{% endfor %}
194194
</tbody>

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/profiler.css.twig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,9 @@ table tbody ul {
200200
.nowrap {
201201
white-space: pre;
202202
}
203+
.prewrap {
204+
white-space: pre-wrap;
205+
}
203206
.newline {
204207
display: block;
205208
}

src/Symfony/Component/HttpFoundation/Response.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,11 @@ public function __construct($content = '', $status = 200, $headers = array())
242242
@trigger_error(sprintf('Extending %s::%s() in %s is deprecated since version 3.2 and won\'t be supported anymore in 4.0 as it will be final.', __CLASS__, $method, $class), E_USER_DEPRECATED);
243243
}
244244
}
245+
246+
/* RFC2616 - 14.18 says all Responses need to have a Date */
247+
if (!$this->headers->has('Date')) {
248+
$this->setDate(new \DateTime(null, new \DateTimeZone('UTC')));
249+
}
245250
}
246251

247252
/**
@@ -370,6 +375,7 @@ public function sendHeaders()
370375
return $this;
371376
}
372377

378+
/* RFC2616 - 14.18 says all Responses need to have a Date */
373379
if (!$this->headers->has('Date')) {
374380
$this->setDate(\DateTime::createFromFormat('U', time()));
375381
}
@@ -657,6 +663,11 @@ public function mustRevalidate()
657663
*/
658664
public function getDate()
659665
{
666+
/*
667+
RFC2616 - 14.18 says all Responses need to have a Date.
668+
Make sure we provide one even if it the header
669+
has been removed in the meantime.
670+
*/
660671
if (!$this->headers->has('Date')) {
661672
$this->setDate(\DateTime::createFromFormat('U', time()));
662673
}

src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,10 @@ public function testGetDate()
276276
$this->assertEquals($now->getTimestamp(), $date->getTimestamp(), '->getDate() returns the date when the header has been modified');
277277

278278
$response = new Response('', 200);
279+
$now = $this->createDateTimeNow();
279280
$response->headers->remove('Date');
280-
$this->assertInstanceOf('\DateTime', $response->getDate());
281+
$date = $response->getDate();
282+
$this->assertEquals($now->getTimestamp(), $date->getTimestamp(), '->getDate() returns the current Date when the header has previously been removed');
281283
}
282284

283285
public function testGetMaxAge()

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
@@ -33,7 +33,9 @@ class UrlValidator extends ConstraintValidator
3333
\] # an IPv6 address
3434
)
3535
(:[0-9]+)? # a port (optional)
36-
(/?|/\S+|\?\S*|\#\S*) # a /, nothing, a / with something, a query or a fragment
36+
(?:/ (?:[\pL\pN\-._\~!$&\'()*+,;=:@]|%%[0-9A-Fa-f]{2})* )* # a path
37+
(?:\? (?:[\pL\pN\-._\~!$&\'()*+,;=:@/?]|%%[0-9A-Fa-f]{2})* )? # a query (optional)
38+
(?:\# (?:[\pL\pN\-._\~!$&\'()*+,;=:@/?]|%%[0-9A-Fa-f]{2})* )? # a fragment (optional)
3739
$~ixu';
3840

3941
/**

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ public function getValidUrls()
123123
array('http://symfony.com#'),
124124
array('http://symfony.com#fragment'),
125125
array('http://symfony.com/#fragment'),
126+
array('http://symfony.com/#one_more%20test'),
126127
);
127128
}
128129

@@ -163,6 +164,9 @@ public function getInvalidUrls()
163164
array('http://:password@@symfony.com'),
164165
array('http://username:passwordsymfony.com'),
165166
array('http://usern@me:password@symfony.com'),
167+
array('http://example.com/exploit.html?<script>alert(1);</script>'),
168+
array('http://example.com/exploit.html?hel lo'),
169+
array('http://example.com/exploit.html?not_a%hex'),
166170
);
167171
}
168172

0 commit comments

Comments
 (0)