Skip to content

Commit afed1c8

Browse files
committed
Merge branch '2.6' into 2.7
* 2.6: (46 commits) fixxed order of usage [2.7] [Form] Replaced calls to array_search() by in_array() where is no need to get the index [Process] Make test AbstractProcessTest::testStartAfterATimeout useful again removed non-sense example Fixes small typo. [Validator] Remove unnecessary include in tests [HttpFoundation] minor: clarify Request::getUrlencodedPrefix() regex fixed typo [Validator] fix DOS-style line endings Drop useless execution bit bumped Symfony version to 2.6.5 [Serializer] update changelog updated VERSION for 2.6.4 updated CHANGELOG for 2.6.4 bumped Symfony version to 2.5.11 [HttpKernel] Added use of provided by #12022 method to instantiate controller class in bundle's controller resolver updated VERSION for 2.5.10 updated CHANGELOG for 2.5.10 [Validator] Add a Russian translation for invalid charset message [2.3] [Validator] spanish translation for invalid charset message ... Conflicts: src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php src/Symfony/Component/HttpKernel/Exception/FatalErrorException.php src/Symfony/Component/HttpKernel/Exception/FlattenException.php src/Symfony/Component/HttpKernel/Kernel.php src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php src/Symfony/Component/Validator/Resources/translations/validators.de.xlf src/Symfony/Component/Validator/Resources/translations/validators.en.xlf src/Symfony/Component/Validator/Resources/translations/validators.es.xlf src/Symfony/Component/Validator/Resources/translations/validators.fr.xlf src/Symfony/Component/Validator/Resources/translations/validators.pl.xlf src/Symfony/Component/Validator/Resources/translations/validators.ru.xlf src/Symfony/Component/Validator/Resources/translations/validators.sl.xlf
2 parents 37c51b8 + 0bd05cc commit afed1c8

File tree

4 files changed

+38
-14
lines changed

4 files changed

+38
-14
lines changed

DataCollector/DumpDataCollector.php

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\HttpFoundation\Response;
1616
use Symfony\Component\Stopwatch\Stopwatch;
1717
use Symfony\Component\VarDumper\Cloner\Data;
18+
use Symfony\Component\VarDumper\Cloner\VarCloner;
1819
use Symfony\Component\VarDumper\Dumper\CliDumper;
1920
use Symfony\Component\VarDumper\Dumper\HtmlDumper;
2021
use Symfony\Component\VarDumper\Dumper\DataDumperInterface;
@@ -31,11 +32,13 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
3132
private $clonesCount = 0;
3233
private $clonesIndex = 0;
3334
private $rootRefs;
35+
private $charset;
3436

35-
public function __construct(Stopwatch $stopwatch = null, $fileLinkFormat = null)
37+
public function __construct(Stopwatch $stopwatch = null, $fileLinkFormat = null, $charset = null)
3638
{
3739
$this->stopwatch = $stopwatch;
3840
$this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
41+
$this->charset = $charset ?: ini_get('php.output_encoding') ?: ini_get('default_charset') ?: 'UTF-8';
3942

4043
// All clones share these properties by reference:
4144
$this->rootRefs = array(
@@ -98,7 +101,7 @@ public function dump(Data $data)
98101
$fileExcerpt = array();
99102

100103
for ($i = max($line - 3, 1), $max = min($line + 3, count($src)); $i <= $max; ++$i) {
101-
$fileExcerpt[] = '<li'.($i === $line ? ' class="selected"' : '').'><code>'.htmlspecialchars($src[$i - 1]).'</code></li>';
104+
$fileExcerpt[] = '<li'.($i === $line ? ' class="selected"' : '').'><code>'.$this->htmlEncode($src[$i - 1]).'</code></li>';
102105
}
103106

104107
$fileExcerpt = '<ol start="'.max($line - 3, 1).'">'.implode("\n", $fileExcerpt).'</ol>';
@@ -158,7 +161,7 @@ public function getDumps($format, $maxDepthLimit = -1, $maxItemsPerDepth = -1)
158161
$data = fopen('php://memory', 'r+b');
159162

160163
if ('html' === $format) {
161-
$dumper = new HtmlDumper($data);
164+
$dumper = new HtmlDumper($data, $this->charset);
162165
} else {
163166
throw new \InvalidArgumentException(sprintf('Invalid dump format: %s', $format));
164167
}
@@ -195,19 +198,18 @@ public function __destruct()
195198
}
196199

197200
if ('cli' !== PHP_SAPI && stripos($h[$i], 'html')) {
198-
echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">';
199-
$dumper = new HtmlDumper('php://output');
201+
$dumper = new HtmlDumper('php://output', $this->charset);
200202
} else {
201-
$dumper = new CliDumper('php://output');
203+
$dumper = new CliDumper('php://output', $this->charset);
202204
$dumper->setColors(false);
203205
}
204206

205207
foreach ($this->data as $i => $dump) {
206208
$this->data[$i] = null;
207209

208210
if ($dumper instanceof HtmlDumper) {
209-
$dump['name'] = htmlspecialchars($dump['name'], ENT_QUOTES, 'UTF-8');
210-
$dump['file'] = htmlspecialchars($dump['file'], ENT_QUOTES, 'UTF-8');
211+
$dump['name'] = $this->htmlEncode($dump['name']);
212+
$dump['file'] = $this->htmlEncode($dump['file']);
211213
if ('' !== $dump['file']) {
212214
if ($this->fileLinkFormat) {
213215
$link = strtr($this->fileLinkFormat, array('%f' => $dump['file'], '%l' => $dump['line']));
@@ -227,4 +229,18 @@ public function __destruct()
227229
$this->dataCount = 0;
228230
}
229231
}
232+
233+
private function htmlEncode($s)
234+
{
235+
$html = '';
236+
237+
$dumper = new HtmlDumper(function ($line) use (&$html) {$html .= $line;}, $this->charset);
238+
$dumper->setDumpHeader('');
239+
$dumper->setDumpBoundaries('', '');
240+
241+
$cloner = new VarCloner();
242+
$dumper->dump($cloner->cloneVar($s));
243+
244+
return substr(strip_tags($html), 1, -1);
245+
}
230246
}

Exception/FatalErrorException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
trigger_error('The '.__NAMESPACE__.'\FatalErrorException class is deprecated since version 2.3 and will be removed in 3.0. Use the Symfony\Component\Debug\Exception\FatalErrorException class instead.', E_USER_DEPRECATED);
1515

16-
/**
16+
/*
1717
* Fatal Error Exception.
1818
*
1919
* @author Konstanton Myakshin <koc-dp@yandex.ru>

Exception/FlattenException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
trigger_error('The '.__NAMESPACE__.'\FlattenException class is deprecated since version 2.3 and will be removed in 3.0. Use the Symfony\Component\Debug\Exception\FlattenException class instead.', E_USER_DEPRECATED);
1515

16-
/**
16+
/*
1717
* FlattenException wraps a PHP Exception to be able to serialize it.
1818
*
1919
* Basically, this class removes all objects from the trace.

Tests/KernelTest.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\HttpKernel\Tests;
1313

14+
use Symfony\Component\DependencyInjection\ContainerBuilder;
1415
use Symfony\Component\HttpKernel\Config\EnvParametersResource;
1516
use Symfony\Component\HttpKernel\Kernel;
1617
use Symfony\Component\HttpKernel\HttpKernelInterface;
@@ -114,7 +115,7 @@ public function testClassCacheIsNotLoadedWhenKernelIsNotBooted()
114115

115116
public function testEnvParametersResourceIsAdded()
116117
{
117-
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder');
118+
$container = new ContainerBuilder();
118119
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest')
119120
->disableOriginalConstructor()
120121
->setMethods(array('getContainerBuilder', 'prepareContainer', 'getCacheDir', 'getLogDir'))
@@ -131,14 +132,21 @@ public function testEnvParametersResourceIsAdded()
131132
$kernel->expects($this->any())
132133
->method('getLogDir')
133134
->will($this->returnValue(sys_get_temp_dir()));
134-
$container->expects($this->once())
135-
->method('addResource')
136-
->with(new EnvParametersResource('SYMFONY__'));
137135

138136
$reflection = new \ReflectionClass(get_class($kernel));
139137
$method = $reflection->getMethod('buildContainer');
140138
$method->setAccessible(true);
141139
$method->invoke($kernel);
140+
141+
$found = false;
142+
foreach ($container->getResources() as $resource) {
143+
if ($resource instanceof EnvParametersResource) {
144+
$found = true;
145+
break;
146+
}
147+
}
148+
149+
$this->assertTrue($found);
142150
}
143151

144152
public function testBootKernelSeveralTimesOnlyInitializesBundlesOnce()

0 commit comments

Comments
 (0)