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

Skip to content

Commit d04c0ea

Browse files
Merge branch '2.7' into 2.8
* 2.7: [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 e71c4f7 + 2059609 commit d04c0ea

File tree

7 files changed

+40
-2
lines changed

7 files changed

+40
-2
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1587,6 +1587,13 @@ private function export($value)
15871587
return $dirname;
15881588
}
15891589

1590+
if (is_string($value) && false !== strpos($value, "\n")) {
1591+
$cleanParts = explode("\n", $value);
1592+
$cleanParts = array_map(function ($part) { return var_export($part, true); }, $cleanParts);
1593+
1594+
return implode('."\n".', $cleanParts);
1595+
}
1596+
15901597
return var_export($value, true);
15911598
}
15921599
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public function testDumpOptimizationString()
5555
'optimize concatenation with empty string' => 'string1%empty_value%string2',
5656
'optimize concatenation from the start' => '%empty_value%start',
5757
'optimize concatenation at the end' => 'end%empty_value%',
58+
'new line' => "string with \nnew line",
5859
));
5960

6061
$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
@@ -56,7 +56,7 @@ public function isFrozen()
5656
*/
5757
protected function getTestService()
5858
{
59-
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'));
59+
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'));
6060
}
6161

6262
/**

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
$sizeInt = (int) $maxSize;

0 commit comments

Comments
 (0)