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

Skip to content

Commit 58efb98

Browse files
committed
Merge branch '2.6' into 2.7
* 2.6: (30 commits) [Translation] fixed JSON loader on PHP 7 when file is empty 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 fixed typo [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 [2.6] Fix HTML escaping of to-source links Fix HTML escaping of to-source links ExceptionHandler: More Encoding Fix the rendering of deprecation log messages [FrameworkBundle] Removed unnecessary parameter in TemplateController [DomCrawler] Throw an exception if a form field path is incomplete. Fixed the indentation in the compiled template for the DumpNode [Console] Delete duplicate test in CommandTest [TwigBundle] Refresh twig paths when resources change. WebProfiler break words ... Conflicts: src/Symfony/Bridge/Twig/composer.json src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/logger.html.twig src/Symfony/Component/Debug/ExceptionHandler.php
2 parents 3e7b19e + dd744c9 commit 58efb98

File tree

42 files changed

+443
-66
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+443
-66
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ not suitable to run Symfony (https://bugs.php.net/bug.php?id=62715)
2222
Installation
2323
------------
2424

25-
The best way to install Symfony is to download the Symfony Standard Edition
26-
available at <https://symfony.com/download>.
25+
The best way to install Symfony is to use the [official Symfony Installer][7].
26+
It allows you to start a new project based on the version you want.
2727

2828
Documentation
2929
-------------
@@ -53,3 +53,4 @@ Information on how to run the Symfony test suite can be found in the
5353
[4]: https://symfony.com/doc/current/contributing/code/patches.html#check-list
5454
[5]: https://symfony.com/doc/current/contributing/code/patches.html#make-a-pull-request
5555
[6]: https://symfony.com/doc/master/contributing/code/tests.html
56+
[7]: https://symfony.com/doc/current/book/installation.html#installing-the-symfony-installer

src/Symfony/Bridge/Twig/Extension/CodeExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function getFilters()
4949
new \Twig_SimpleFilter('file_excerpt', array($this, 'fileExcerpt'), array('is_safe' => array('html'))),
5050
new \Twig_SimpleFilter('format_file', array($this, 'formatFile'), array('is_safe' => array('html'))),
5151
new \Twig_SimpleFilter('format_file_from_text', array($this, 'formatFileFromText'), array('is_safe' => array('html'))),
52-
new \Twig_SimpleFilter('file_link', array($this, 'getFileLink'), array('is_safe' => array('html'))),
52+
new \Twig_SimpleFilter('file_link', array($this, 'getFileLink')),
5353
);
5454
}
5555

src/Symfony/Bridge/Twig/Node/DumpNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,6 @@ public function compile(\Twig_Compiler $compiler)
7979

8080
$compiler
8181
->outdent()
82-
->raw("}\n");
82+
->write("}\n");
8383
}
8484
}

src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@
231231
{% if form.parent %}<span class="help-block">{% else %}<div class="alert alert-danger">{% endif %}
232232
<ul class="list-unstyled">
233233
{%- for error in errors -%}
234-
<li><span class="glyphicon glyphicon-exclamation-sign"></span>{{ error.message }}</li>
234+
<li><span class="glyphicon glyphicon-exclamation-sign"></span> {{ error.message }}</li>
235235
{%- endfor -%}
236236
</ul>
237237
{% if form.parent %}</span>{% else %}</div>{% endif %}

src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,30 @@ public function testNoVar()
3939
$this->assertSame($expected, $compiler->compile($node)->getSource());
4040
}
4141

42+
public function testIndented()
43+
{
44+
$node = new DumpNode('bar', null, 7);
45+
46+
$env = new \Twig_Environment();
47+
$compiler = new \Twig_Compiler($env);
48+
49+
$expected = <<<'EOTXT'
50+
if ($this->env->isDebug()) {
51+
$barvars = array();
52+
foreach ($context as $barkey => $barval) {
53+
if (!$barval instanceof \Twig_Template) {
54+
$barvars[$barkey] = $barval;
55+
}
56+
}
57+
// line 7
58+
\Symfony\Component\VarDumper\VarDumper::dump($barvars);
59+
}
60+
61+
EOTXT;
62+
63+
$this->assertSame($expected, $compiler->compile($node, 1)->getSource());
64+
}
65+
4266
public function testOneVar()
4367
{
4468
$vars = new \Twig_Node(array(

src/Symfony/Bundle/FrameworkBundle/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;

src/Symfony/Bundle/FrameworkBundle/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;

src/Symfony/Bundle/FrameworkBundle/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 <[email protected]>
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 <[email protected]>
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+
}

src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bundle\TwigBundle\DependencyInjection;
1313

1414
use Symfony\Component\Config\FileLocator;
15+
use Symfony\Component\Config\Resource\DirectoryResource;
1516
use Symfony\Component\DependencyInjection\ContainerBuilder;
1617
use Symfony\Component\DependencyInjection\Reference;
1718
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
@@ -74,22 +75,26 @@ public function load(array $configs, ContainerBuilder $container)
7475
} else {
7576
$twigFilesystemLoaderDefinition->addMethodCall('addPath', array($path, $namespace));
7677
}
78+
$container->addResource(new DirectoryResource($path));
7779
}
7880

7981
// register bundles as Twig namespaces
8082
foreach ($container->getParameter('kernel.bundles') as $bundle => $class) {
8183
if (is_dir($dir = $container->getParameter('kernel.root_dir').'/Resources/'.$bundle.'/views')) {
8284
$this->addTwigPath($twigFilesystemLoaderDefinition, $dir, $bundle);
85+
$container->addResource(new DirectoryResource($dir));
8386
}
8487

8588
$reflection = new \ReflectionClass($class);
8689
if (is_dir($dir = dirname($reflection->getFilename()).'/Resources/views')) {
8790
$this->addTwigPath($twigFilesystemLoaderDefinition, $dir, $bundle);
91+
$container->addResource(new DirectoryResource($dir));
8892
}
8993
}
9094

9195
if (is_dir($dir = $container->getParameter('kernel.root_dir').'/Resources/views')) {
9296
$twigFilesystemLoaderDefinition->addMethodCall('addPath', array($dir));
97+
$container->addResource(new DirectoryResource($dir));
9398
}
9499

95100
if (!empty($config['globals'])) {

src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function getConfigTreeBuilder()
4545
->end()
4646
->end()
4747
->booleanNode('intercept_redirects')->defaultFalse()->end()
48-
->scalarNode('excluded_ajax_paths')->defaultValue('^/bundles|^/_wdt')->end()
48+
->scalarNode('excluded_ajax_paths')->defaultValue('^/(app(_[\\w]+)?\\.php/)?_wdt')->end()
4949
->end()
5050
;
5151

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,17 @@
213213
var self = this;
214214
215215
/* prevent logging AJAX calls to static and inline files, like templates */
216-
if (url.substr(0, 1) === '/' && !url.match(new RegExp("{{ excluded_ajax_paths }}"))) {
216+
var path = url;
217+
if (url.substr(0, 1) === '/') {
218+
if (0 === url.indexOf('{{ app.request.basePath|e('js') }}')) {
219+
path = url.substr({{ app.request.basePath|length }});
220+
}
221+
}
222+
else if (0 === url.indexOf('{{ (app.request.schemeAndHttpHost ~ app.request.basePath)|e('js') }}')) {
223+
path = url.substr({{ (app.request.schemeAndHttpHost ~ app.request.basePath)|length }});
224+
}
225+
226+
if (path.substr(0, 1) === '/' && !path.match(new RegExp({{ excluded_ajax_paths|json_encode|raw }}))) {
217227
var stackElement = {
218228
loading: true,
219229
error: false,

src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/ConfigurationTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ public function testConfigTree($options, $results)
3131
public function getDebugModes()
3232
{
3333
return array(
34-
array(array(), array('intercept_redirects' => false, 'toolbar' => false, 'position' => 'bottom', 'excluded_ajax_paths' => '^/bundles|^/_wdt')),
35-
array(array('intercept_redirects' => true), array('intercept_redirects' => true, 'toolbar' => false, 'position' => 'bottom', 'excluded_ajax_paths' => '^/bundles|^/_wdt')),
36-
array(array('intercept_redirects' => false), array('intercept_redirects' => false, 'toolbar' => false, 'position' => 'bottom', 'excluded_ajax_paths' => '^/bundles|^/_wdt')),
37-
array(array('toolbar' => true), array('intercept_redirects' => false, 'toolbar' => true, 'position' => 'bottom', 'excluded_ajax_paths' => '^/bundles|^/_wdt')),
38-
array(array('position' => 'top'), array('intercept_redirects' => false, 'toolbar' => false, 'position' => 'top', 'excluded_ajax_paths' => '^/bundles|^/_wdt')),
34+
array(array(), array('intercept_redirects' => false, 'toolbar' => false, 'position' => 'bottom', 'excluded_ajax_paths' => '^/(app(_[\\w]+)?\\.php/)?_wdt')),
35+
array(array('intercept_redirects' => true), array('intercept_redirects' => true, 'toolbar' => false, 'position' => 'bottom', 'excluded_ajax_paths' => '^/(app(_[\\w]+)?\\.php/)?_wdt')),
36+
array(array('intercept_redirects' => false), array('intercept_redirects' => false, 'toolbar' => false, 'position' => 'bottom', 'excluded_ajax_paths' => '^/(app(_[\\w]+)?\\.php/)?_wdt')),
37+
array(array('toolbar' => true), array('intercept_redirects' => false, 'toolbar' => true, 'position' => 'bottom', 'excluded_ajax_paths' => '^/(app(_[\\w]+)?\\.php/)?_wdt')),
38+
array(array('position' => 'top'), array('intercept_redirects' => false, 'toolbar' => false, 'position' => 'top', 'excluded_ajax_paths' => '^/(app(_[\\w]+)?\\.php/)?_wdt')),
3939
array(array('excluded_ajax_paths' => 'test'), array('intercept_redirects' => false, 'toolbar' => false, 'position' => 'bottom', 'excluded_ajax_paths' => 'test')),
4040
);
4141
}

src/Symfony/Component/Console/Formatter/OutputFormatter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ public function getStyle($name)
142142
*/
143143
public function format($message)
144144
{
145+
$message = (string) $message;
145146
$offset = 0;
146147
$output = '';
147148
$tagRegex = '[a-z][a-z0-9_=;-]*';

0 commit comments

Comments
 (0)