Skip to content

Commit 3f83723

Browse files
committed
Merge branch '2.3' into 2.6
* 2.3: Fix typo Check instance of FormBuilderInterface instead of FormBuilder [Security] TokenBasedRememberMeServices test to show why encoding username is required [Security] AbstractRememberMeServices::encodeCookie() validates cookie parts [console][formater] allow format toString object. [HttpFoundation] Fix baseUrl when script filename is contained in pathInfo Avoid redirection to XHR URIs [HttpFoundation] IpUtils::checkIp4() should allow networks Fix HTML escaping of to-source links [FrameworkBundle] Removed unnecessary parameter in TemplateController [DomCrawler] Throw an exception if a form field path is incomplete. [Console] Delete duplicate test in CommandTest [TwigBundle] Refresh twig paths when resources change. WebProfiler break words fixed typo Update README.md [HttpKernel] Handle an array vary header in the http cache store [Security][Translation] fixes #14584 [Framework] added test for Router commands. Handled bearer authorization header in REDIRECT_ form Conflicts: src/Symfony/Component/Debug/ExceptionHandler.php
2 parents 7643759 + 044c5a1 commit 3f83723

File tree

5 files changed

+193
-9
lines changed

5 files changed

+193
-9
lines changed

Controller/TemplateController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function templateAction($template, $maxAge = null, $sharedAge = null, $pr
4747
if ($private) {
4848
$response->setPrivate();
4949
} elseif ($private === false || (null === $private && ($maxAge || $sharedAge))) {
50-
$response->setPublic($private);
50+
$response->setPublic();
5151
}
5252

5353
return $response;

Resources/public/css/body.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ build: 56
5252
background-color: #FFFFFF;
5353
border: 1px solid #dfdfdf;
5454
padding: 40px 50px;
55+
word-break: break-all;
5556
}
5657
.sf-reset h2 {
5758
font-size: 16px;

Templating/Helper/CodeHelper.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,24 +154,25 @@ public function fileExcerpt($file, $line)
154154
*/
155155
public function formatFile($file, $line, $text = null)
156156
{
157+
if (PHP_VERSION_ID >= 50400) {
158+
$flags = ENT_QUOTES | ENT_SUBSTITUTE;
159+
} else {
160+
$flags = ENT_QUOTES;
161+
}
162+
157163
if (null === $text) {
158164
$file = trim($file);
159165
$fileStr = $file;
160166
if (0 === strpos($fileStr, $this->rootDir)) {
161167
$fileStr = str_replace($this->rootDir, '', str_replace('\\', '/', $fileStr));
162-
$fileStr = sprintf('<abbr title="%s">kernel.root_dir</abbr>/%s', $this->rootDir, $fileStr);
168+
$fileStr = htmlspecialchars($fileStr, $flags, $this->charset);
169+
$fileStr = sprintf('<abbr title="%s">kernel.root_dir</abbr>/%s', htmlspecialchars($this->rootDir, $flags, $this->charset), $fileStr);
163170
}
164171

165-
$text = "$fileStr at line $line";
172+
$text = sprintf('%s at line %d', $fileStr, $line);
166173
}
167174

168175
if (false !== $link = $this->getFileLink($file, $line)) {
169-
if (PHP_VERSION_ID >= 50400) {
170-
$flags = ENT_QUOTES | ENT_SUBSTITUTE;
171-
} else {
172-
$flags = ENT_QUOTES;
173-
}
174-
175176
return sprintf('<a href="%s" title="Click to open this file" class="file_link">%s</a>', htmlspecialchars($link, $flags, $this->charset), $text);
176177
}
177178

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bundle\FrameworkBundle\Tests\Command;
13+
14+
use Symfony\Component\Console\Application;
15+
use Symfony\Component\Console\Tester\CommandTester;
16+
use Symfony\Bundle\FrameworkBundle\Command\RouterDebugCommand;
17+
use Symfony\Component\Routing\Route;
18+
use Symfony\Component\Routing\RouteCollection;
19+
20+
class RouterDebugCommandTest extends \PHPUnit_Framework_TestCase
21+
{
22+
public function testDebugAllRoutes()
23+
{
24+
$tester = $this->createCommandTester();
25+
$ret = $tester->execute(array('name' => null));
26+
27+
$this->assertEquals(0, $ret, 'Returns 0 in case of success');
28+
$this->assertContains('[router] Current routes', $tester->getDisplay());
29+
}
30+
31+
public function testDebugSingleRoute()
32+
{
33+
$tester = $this->createCommandTester();
34+
$ret = $tester->execute(array('name' => 'foo'));
35+
36+
$this->assertEquals(0, $ret, 'Returns 0 in case of success');
37+
$this->assertContains('[router] Route "foo"', $tester->getDisplay());
38+
}
39+
40+
/**
41+
* @expectedException \InvalidArgumentException
42+
*/
43+
public function testDebugInvalidRoute()
44+
{
45+
$this->createCommandTester()->execute(array('name' => 'test'));
46+
}
47+
48+
/**
49+
* @return CommandTester
50+
*/
51+
private function createCommandTester()
52+
{
53+
$application = new Application();
54+
55+
$command = new RouterDebugCommand();
56+
$command->setContainer($this->getContainer());
57+
$application->add($command);
58+
59+
return new CommandTester($application->find('router:debug'));
60+
}
61+
62+
private function getContainer()
63+
{
64+
$routeCollection = new RouteCollection();
65+
$routeCollection->add('foo', new Route('foo'));
66+
$router = $this->getMock('Symfony\Component\Routing\RouterInterface');
67+
$router
68+
->expects($this->atLeastOnce())
69+
->method('getRouteCollection')
70+
->will($this->returnValue($routeCollection))
71+
;
72+
73+
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
74+
$container
75+
->expects($this->once())
76+
->method('has')
77+
->with('router')
78+
->will($this->returnValue(true))
79+
;
80+
$container
81+
->expects($this->atLeastOnce())
82+
->method('get')
83+
->with('router')
84+
->will($this->returnValue($router))
85+
;
86+
87+
return $container;
88+
}
89+
}
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bundle\FrameworkBundle\Tests\Command;
13+
14+
use Symfony\Component\Console\Application;
15+
use Symfony\Component\Console\Tester\CommandTester;
16+
use Symfony\Bundle\FrameworkBundle\Command\RouterMatchCommand;
17+
use Symfony\Bundle\FrameworkBundle\Command\RouterDebugCommand;
18+
use Symfony\Component\Routing\Route;
19+
use Symfony\Component\Routing\RouteCollection;
20+
use Symfony\Component\Routing\RequestContext;
21+
22+
class RouterMatchCommandTest extends \PHPUnit_Framework_TestCase
23+
{
24+
public function testWithMatchPath()
25+
{
26+
$tester = $this->createCommandTester();
27+
$ret = $tester->execute(array('path_info' => '/foo', 'foo'));
28+
29+
$this->assertEquals(0, $ret, 'Returns 0 in case of success');
30+
$this->assertContains('[router] Route "foo"', $tester->getDisplay());
31+
}
32+
33+
public function testWithNotMatchPath()
34+
{
35+
$tester = $this->createCommandTester();
36+
$ret = $tester->execute(array('path_info' => '/test', 'foo'));
37+
38+
$this->assertEquals(1, $ret, 'Returns 1 in case of failure');
39+
$this->assertContains('None of the routes match the path "/test"', $tester->getDisplay());
40+
}
41+
42+
/**
43+
* @return CommandTester
44+
*/
45+
private function createCommandTester()
46+
{
47+
$application = new Application();
48+
49+
$command = new RouterMatchCommand();
50+
$command->setContainer($this->getContainer());
51+
$application->add($command);
52+
53+
$command = new RouterDebugCommand();
54+
$command->setContainer($this->getContainer());
55+
$application->add($command);
56+
57+
return new CommandTester($application->find('router:match'));
58+
}
59+
60+
private function getContainer()
61+
{
62+
$routeCollection = new RouteCollection();
63+
$routeCollection->add('foo', new Route('foo'));
64+
$requestContext = new RequestContext();
65+
$router = $this->getMock('Symfony\Component\Routing\RouterInterface');
66+
$router
67+
->expects($this->any())
68+
->method('getRouteCollection')
69+
->will($this->returnValue($routeCollection))
70+
;
71+
$router
72+
->expects($this->any())
73+
->method('getContext')
74+
->will($this->returnValue($requestContext))
75+
;
76+
77+
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
78+
$container
79+
->expects($this->once())
80+
->method('has')
81+
->with('router')
82+
->will($this->returnValue(true))
83+
;
84+
$container
85+
->expects($this->atLeastOnce())
86+
->method('get')
87+
->with('router')
88+
->will($this->returnValue($router))
89+
;
90+
91+
return $container;
92+
}
93+
}

0 commit comments

Comments
 (0)