8000 Merge branch '2.8' into 3.3 · symfony/symfony@17b48ed · GitHub
[go: up one dir, main page]

Skip to content

Commit 17b48ed

Browse files
Merge branch '2.8' into 3.3
* 2.8: [Validator] added magic method __isset() to File Constraint class [DI] Fix possible incorrect php-code when dumped strings contains newlines [Translation] minor: remove unused variable in test never match invalid IP addresses
2 parents 4ae1f89 + d04c0ea commit 17b48ed

File tree

7 files changed

+40
-3
lines changed

7 files changed

+40
-3
lines changed

src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1724,7 +1724,13 @@ private function export($value)
17241724

17251725
private function doExport($value)
17261726
{
1727-
$export = var_export($value, true);
1727+
if (is_string($value) && false !== strpos($value, "\n")) {
1728+
$cleanParts = explode("\n", $value);
1729+
$cleanParts = array_map(function ($part) { return var_export($part, true); }, $cleanParts);
1730+
$export = implode('."\n".', $cleanParts);
1731+
} else {
1732+
$export = var_export($value, true);
1733+
}
17281734

17291735
if ("'" === $export[0] && $export !== $resolvedExport = $this->container->resolveEnvPlaceholders($export, "'.\$this->getEnv('%s').'")) {
17301736
$export = $resolvedExport;

src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public function testDumpOptimizationString()
6868
'optimize concatenation with empty string' => 'string1%empty_value%string2',
6969
'optimize concatenation from the start' => '%empty_value%start',
7070
'optimize concatenation at the end' => 'end%empty_value%',
71+
'new line' => "string with \nnew line",
7172
));
7273

7374
$container = new ContainerBuilder();

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function isFrozen()
6464
*/
6565
protected function getTestService()
6666
{
67-
return $this->services['test'] = new \stdClass(array('only dot' => '.', 'concatenation as value' => '.\'\'.', 'concatenation from 10000 the start value' => '\'\'.', '.' => 'dot as a key', '.\'\'.' => 'concatenation as a key', '\'\'.' => 'concatenation from the start key', 'optimize concatenation' => 'string1-string2', 'optimize concatenation with empty string' => 'string1string2', 'optimize concatenation from the start' => 'start', 'optimize concatenation at the end' => 'end'));
67+
return $this->services['test'] = new \stdClass(array('only dot' => '.', 'concatenation as value' => '.\'\'.', 'concatenation from the start value' => '\'\'.', '.' => 'dot as a key', '.\'\'.' => 'concatenation as a key', '\'\'.' => 'concatenation from the start key', 'optimize concatenation' => 'string1-string2', 'optimize concatenation with empty string' => 'string1string2', 'optimize concatenation from the start' => 'start', 'optimize concatenation at the end' => 'end', 'new line' => 'string with '."\n".'new line'));
6868
}
6969

7070
/**

src/Symfony/Component/HttpFoundation/IpUtils.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ public static function checkIp4($requestIp, $ip)
8787
$netmask = 32;
8888
}
8989

90+
if (false === ip2long($address)) {
91+
return self::$checkedIps[$cacheKey] = false;
92+
}
93+
9094
return self::$checkedIps[$cacheKey] = 0 === substr_compare(sprintf('%032b', ip2long($requestIp)), sprintf('%032b', ip2long($address)), 0, $netmask);
9195
}
9296

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,21 @@ public function testAnIpv6WithOptionDisabledIpv6()
8282

8383
IpUtils::checkIp('2a01:198:603:0:396e:4789:8e99:890f', '2a01:198:603:0::/65');
8484
}
85+
86+
/**
87+
* @dataProvider invalidIpAddressData
88+
*/
89+
public function testInvalidIpAddressesDoNotMatch($requestIp, $proxyIp)
90+
{
91+
$this->assertFalse(IpUtils::checkIp4($requestIp, $proxyIp));
92+
}
93+
94+
public function invalidIpAddressData()
95+
{
96+
return array(
97+
'invalid proxy wildcard' => array('192.168.20.13', '*'),
98+
'invalid proxy missing netmask' => array('192.168.20.13', '0.0.0.0'),
99+
'invalid request IP with invalid proxy wildcard' => array('0.0.0.0', '*'),
100+
);
101+
}
85102
}

src/Symfony/Component/Translation/Tests/TranslatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class TranslatorTest extends TestCase
2525
*/
2626
public function testConstructorInvalidLocale($locale)
2727
{
28-
$translator = new Translator($locale, new MessageSelector());
28+
new Translator($locale, new MessageSelector());
2929
}
3030

3131
/**

src/Symfony/Component/Validator/Constraints/File.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,15 @@ public function __get($option)
8888
return parent::__get($option);
8989
}
9090

91+
public function __isset($option)
92+
{
93+
if ('maxSize' === $option) {
94+
return true;
95+
}
96+
97+
return parent::__isset($option);
98+
}
99+
91100
private function normalizeBinaryFormat($maxSize)
92101
{
93102
$factors = array(

0 commit comments

Comments
 (0)
0