Skip to content

Commit 444a840

Browse files
Merge branch '3.2' into 3.3
* 3.2: use Precise on Travis to keep PHP LDAP support Fix case sensitive sameSite cookie [PropertyInfo] Use rawurlencode to escape PSR-6 keys fix(security): ensure the 'route' index is set before attempting to use it [WebProfilerBundle] Fix full sized dump hovering in toolbar
2 parents 34d5f9e + 0793fe7 commit 444a840

File tree

8 files changed

+31
-57
lines changed

8 files changed

+31
-57
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
language: php
22

3+
dist: precise
34
sudo: false
45

56
git:

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -373,13 +373,12 @@
373373
100% { background: #222; }
374374
}
375375

376-
.sf-toolbar-block.sf-toolbar-block-dump {
377-
position: static;
378-
}
379-
380376
.sf-toolbar-block.sf-toolbar-block-dump .sf-toolbar-info {
381377
max-width: none;
382-
right: 0;
378+
width: 100%;
379+
position: fixed;
380+
box-sizing: border-box;
381+
left: 0;
383382
}
384383

385384
.sf-toolbar-block-dump pre.sf-dump {

src/Symfony/Component/HttpFoundation/Cookie.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ public function __construct($name, $value = null, $expire = 0, $path = '/', $dom
126126
$this->httpOnly = (bool) $httpOnly;
127127
$this->raw = (bool) $raw;
128128

129+
if (null !== $sameSite) {
130+
$sameSite = strtolower($sameSite);
131+
}
132+
129133
if (!in_array($sameSite, array(self::SAMESITE_LAX, self::SAMESITE_STRICT, null), true)) {
130134
throw new \InvalidArgumentException('The "sameSite" parameter value is not valid.');
131135
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,4 +214,10 @@ public function testFromStringWithHttpOnly()
214214
$cookie = Cookie::fromString('foo=bar; expires=Fri, 20-May-2011 15:25:52 GMT; path=/; domain=.myfoodomain.com; secure');
215215
$this->assertFalse($cookie->isHttpOnly());
216216
}
217+
218+
public function testSameSiteAttributeIsCaseInsensitive()
219+
{
220+
$cookie = new Cookie('foo', 'bar', 0, '/', null, false, true, false, 'Lax');
221+
$this->assertEquals('lax', $cookie->getSameSite());
222+
}
217223
}

src/Symfony/Component/PropertyInfo/PropertyInfoCacheExtractor.php

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ private function extract($method, array $arguments)
108108
return call_user_func_array(array($this->propertyInfoExtractor, $method), $arguments);
109109
}
110110

111-
$key = $this->escape($method.'.'.$serializedArguments);
111+
// Calling rawurlencode escapes special characters not allowed in PSR-6's keys
112+
$key = rawurlencode($method.'.'.$serializedArguments);
112113

113114
if (array_key_exists($key, $this->arrayCache)) {
114115
return $this->arrayCache[$key];
@@ -126,29 +127,4 @@ private function extract($method, array $arguments)
126127

127128
return $this->arrayCache[$key] = $value;
128129
}
129-
130-
/**
131-
* Escapes a key according to PSR-6.
132-
*
133-
* Replaces characters forbidden by PSR-6 and the _ char by the _ char followed by the ASCII
134-
* code of the escaped char.
135-
*
136-
* @param string $key
137-
*
138-
* @return string
139-
*/
140-
private function escape($key)
141-
{
142-
return strtr($key, array(
143-
'{' => '_123',
144-
'}' => '_125',
145-
'(' => '_40',
146-
')' => '_41',
147-
'/' => '_47',
148-
'\\' => '_92',
149-
'@' => '_64',
150-
':' => '_58',
151-
'_' => '_95',
152-
));
153-
}
154130
}

src/Symfony/Component/PropertyInfo/Tests/PropertyInfoCacheExtractorTest.php

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -61,29 +61,4 @@ public function testGetProperties()
6161
parent::testGetProperties();
6262
parent::testGetProperties();
6363
}
64-
65-
/**
66-
* @dataProvider escapeDataProvider
67-
*/
68-
public function testEscape($toEscape, $expected)
69-
{
70-
$reflectionMethod = new \ReflectionMethod($this->propertyInfo, 'escape');
71-
$reflectionMethod->setAccessible(true);
72-
73-
$this->assertSame($expected, $reflectionMethod->invoke($this->propertyInfo, $toEscape));
74-
}
75-
76-
public function escapeDataProvider()
77-
{
78-
return array(
79-
array('foo_bar', 'foo_95bar'),
80-
array('foo_95bar', 'foo_9595bar'),
81-
array('foo{bar}', 'foo_123bar_125'),
82-
array('foo(bar)', 'foo_40bar_41'),
83-
array('foo/bar', 'foo_47bar'),
84-
array('foo\bar', 'foo_92bar'),
85-
array('foo@bar', 'foo_64bar'),
86-
array('foo:bar', 'foo_58bar'),
87-
);
88-
}
8964
}

src/Symfony/Component/Security/Http/HttpUtils.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public function checkRequestPath(Request $request, $path)
108108
$parameters = $this->urlMatcher->match($request->getPathInfo());
109109
}
110110

111-
return $path === $parameters['_route'];
111+
return isset($parameters['_route']) && $path === $parameters['_route'];
112112
} catch (MethodNotAllowedException $e) {
113113
return false;
114114
} catch (ResourceNotFoundException $e) {

src/Symfony/Component/Security/Http/Tests/HttpUtilsTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,19 @@ public function testCheckRequestPathWithUrlMatcherLoadingException()
221221
$utils->checkRequestPath($this->getRequest(), 'foobar');
222222
}
223223

224+
public function testCheckPathWithoutRouteParam()
225+
{
226+
$urlMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\UrlMatcherInterface')->getMock();
227+
$urlMatcher
228+
->expects($this->any())
229+
->method('match')
230+
->willReturn(array('_controller' => 'PathController'))
231+
;
232+
233+
$utils = new HttpUtils(null, $urlMatcher);
234+
$this->assertFalse($utils->checkRequestPath($this->getRequest(), 'path/index.html'));
235+
}
236+
224237
/**
225238
* @expectedException \InvalidArgumentException
226239
* @expectedExceptionMessage Matcher must either implement UrlMatcherInterface or RequestMatcherInterface

0 commit comments

Comments
 (0)