Merge branch '2.3' into 2.7
* 2.3: [Request] Ignore invalid IP addresses sent by proxies Able to load big xml files with DomCrawler fixed typo [Form] Fix constraints could be null if not set [Finder] Check PHP version before applying a workaround for a PHP bug fixed CS sort bundles in config:dump-reference command Fixer findings.
This commit is contained in:
commit
2173c78da2
@ -36,6 +36,7 @@ class TransNodeTest extends \PHPUnit_Framework_TestCase
|
||||
trim($compiler->compile($node)->getSource())
|
||||
);
|
||||
}
|
||||
|
||||
protected function getVariableGetterWithoutStrictCheck($name)
|
||||
{
|
||||
if (PHP_VERSION_ID >= 50400) {
|
||||
|
@ -83,6 +83,7 @@ abstract class AbstractDescriptorTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
abstract protected function getDescriptor();
|
||||
|
||||
abstract protected function getFormat();
|
||||
|
||||
private function getDescriptionTestData(array $objects)
|
||||
|
@ -28,5 +28,6 @@ abstract class AbstractNodeTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
abstract public function getToStringConversionTestData();
|
||||
|
||||
abstract public function getSpecificityValueTestData();
|
||||
}
|
||||
|
@ -43,7 +43,9 @@ abstract class AbstractHandlerTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
abstract public function getHandleValueTestData();
|
||||
|
||||
abstract public function getDontHandleValueTestData();
|
||||
|
||||
abstract protected function generateHandler();
|
||||
|
||||
protected function assertStreamEmpty(TokenStream $stream)
|
||||
|
@ -244,7 +244,7 @@ class Crawler extends \SplObjectStorage
|
||||
$dom->validateOnParse = true;
|
||||
|
||||
if ('' !== trim($content)) {
|
||||
@$dom->loadXML($content, LIBXML_NONET);
|
||||
@$dom->loadXML($content, LIBXML_NONET | (defined('LIBXML_PARSEHUGE') ? LIBXML_PARSEHUGE : 0));
|
||||
}
|
||||
|
||||
libxml_use_internal_errors($internalErrors);
|
||||
|
@ -12,9 +12,10 @@
|
||||
namespace Symfony\Component\Finder\Iterator;
|
||||
|
||||
/**
|
||||
* This iterator just overrides the rewind method in order to correct a PHP bug.
|
||||
* This iterator just overrides the rewind method in order to correct a PHP bug,
|
||||
* which existed before version 5.5.23/5.6.7.
|
||||
*
|
||||
* @see https://bugs.php.net/bug.php?id=49104
|
||||
* @see https://bugs.php.net/68557
|
||||
*
|
||||
* @author Alex Bogomazov
|
||||
*/
|
||||
@ -28,19 +29,20 @@ abstract class FilterIterator extends \FilterIterator
|
||||
*/
|
||||
public function rewind()
|
||||
{
|
||||
if (PHP_VERSION_ID > 50607 || (PHP_VERSION_ID > 50523 && PHP_VERSION_ID < 50600)) {
|
||||
parent::rewind();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$iterator = $this;
|
||||
while ($iterator instanceof \OuterIterator) {
|
||||
$innerIterator = $iterator->getInnerIterator();
|
||||
|
||||
if ($innerIterator instanceof RecursiveDirectoryIterator) {
|
||||
if ($innerIterator->isRewindable()) {
|
||||
if ($innerIterator instanceof \FilesystemIterator) {
|
||||
$innerIterator->next();
|
||||
$innerIterator->rewind();
|
||||
}
|
||||
} elseif ($iterator->getInnerIterator() instanceof \FilesystemIterator) {
|
||||
$iterator->getInnerIterator()->next();
|
||||
$iterator->getInnerIterator()->rewind();
|
||||
}
|
||||
$iterator = $iterator->getInnerIterator();
|
||||
}
|
||||
|
||||
|
@ -118,8 +118,10 @@ class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
|
||||
return;
|
||||
}
|
||||
|
||||
// @see https://bugs.php.net/bug.php?id=49104
|
||||
// @see https://bugs.php.net/68557
|
||||
if (PHP_VERSION_ID < 50523 || PHP_VERSION_ID >= 50600 && PHP_VERSION_ID < 50607) {
|
||||
parent::next();
|
||||
}
|
||||
|
||||
parent::rewind();
|
||||
}
|
||||
|
@ -467,7 +467,7 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
* Searching in multiple locations involves AppendIterator which does an unnecessary rewind which leaves FilterIterator
|
||||
* with inner FilesystemIterator in an invalid state.
|
||||
*
|
||||
* @see https://bugs.php.net/bug.php?id=49104
|
||||
* @see https://bugs.php.net/68557
|
||||
*/
|
||||
public function testMultipleLocations()
|
||||
{
|
||||
@ -477,8 +477,12 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
);
|
||||
|
||||
// it is expected that there are test.py test.php in the tmpDir
|
||||
$finder = $this->buildFinder();
|
||||
$finder->in($locations)->depth('< 1')->name('test.php');
|
||||
$finder = new Finder();
|
||||
$finder->in($locations)
|
||||
// the default flag IGNORE_DOT_FILES fixes the problem indirectly
|
||||
// so we set it to false for better isolation
|
||||
->ignoreDotFiles(false)
|
||||
->depth('< 1')->name('test.php');
|
||||
|
||||
$this->assertCount(1, $finder);
|
||||
}
|
||||
@ -488,7 +492,7 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
* AppendIterator which does an unnecessary rewind which leaves
|
||||
* FilterIterator with inner FilesystemIterator in an invalid state.
|
||||
*
|
||||
* @see https://bugs.php.net/bug.php?id=49104
|
||||
* @see https://bugs.php.net/68557
|
||||
*/
|
||||
public function testMultipleLocationsWithSubDirectories()
|
||||
{
|
||||
|
@ -43,8 +43,9 @@ class FilterIteratorTest extends RealIteratorTestCase
|
||||
++$c;
|
||||
}
|
||||
|
||||
// This would fail with \FilterIterator but works with Symfony\Component\Finder\Iterator\FilterIterator
|
||||
// see https://bugs.php.net/bug.php?id=49104
|
||||
// This would fail in php older than 5.5.23/5.6.7 with \FilterIterator
|
||||
// but works with Symfony\Component\Finder\Iterator\FilterIterator
|
||||
// see https://bugs.php.net/68557
|
||||
$this->assertEquals(1, $c);
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ class FormValidator extends ConstraintValidator
|
||||
|
||||
// Validate the data against the constraints defined
|
||||
// in the form
|
||||
$constraints = $config->getOption('constraints');
|
||||
$constraints = $config->getOption('constraints', array());
|
||||
foreach ($constraints as $constraint) {
|
||||
foreach ($groups as $group) {
|
||||
if (in_array($group, $constraint->groups)) {
|
||||
|
@ -28,6 +28,7 @@ class HttpFoundationRequestHandlerTest extends AbstractRequestHandlerTest
|
||||
{
|
||||
$this->requestHandler->handleRequest($this->getMockForm('name', 'GET'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
|
||||
*/
|
||||
|
@ -129,6 +129,17 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testMissingConstraintIndex()
|
||||
{
|
||||
$object = new \stdClass();
|
||||
$form = new FormBuilder('name', '\stdClass', $this->dispatcher, $this->factory);
|
||||
$form = $form->setData($object)->getForm();
|
||||
|
||||
$this->validator->validate($form, new Form());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testValidateConstraintsEvenIfNoCascadeValidation()
|
||||
{
|
||||
$object = $this->getMock('\stdClass');
|
||||
|
@ -814,7 +814,7 @@ class Request
|
||||
}
|
||||
|
||||
$clientIps[] = $ip; // Complete the IP chain with the IP the request actually came from
|
||||
$ip = $clientIps[0]; // Fallback to this when the client IP falls into the range of trusted proxies
|
||||
$firstTrustedIp = null;
|
||||
|
||||
foreach ($clientIps as $key => $clientIp) {
|
||||
// Remove port (unfortunately, it does happen)
|
||||
@ -822,13 +822,22 @@ class Request
|
||||
$clientIps[$key] = $clientIp = $match[1];
|
||||
}
|
||||
|
||||
if (!filter_var($clientIp, FILTER_VALIDATE_IP)) {
|
||||
unset($clientIps[$key]);
|
||||
}
|
||||
|
||||
if (IpUtils::checkIp($clientIp, self::$trustedProxies)) {
|
||||
unset($clientIps[$key]);
|
||||
|
||||
// Fallback to this when the client IP falls into the range of trusted proxies
|
||||
if (null === $firstTrustedIp) {
|
||||
$firstTrustedIp = $clientIp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now the IP chain contains only untrusted proxies and the client IP
|
||||
return $clientIps ? array_reverse($clientIps) : array($ip);
|
||||
return $clientIps ? array_reverse($clientIps) : array($firstTrustedIp);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1019,11 +1019,12 @@ class Response
|
||||
return $notModified;
|
||||
}
|
||||
|
||||
// http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
|
||||
/**
|
||||
* Is response invalid?
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
|
||||
*/
|
||||
public function isInvalid()
|
||||
{
|
||||
|
@ -909,6 +909,9 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
// client IP with port
|
||||
array(array('88.88.88.88'), '127.0.0.1', '88.88.88.88:12345, 127.0.0.1', array('127.0.0.1')),
|
||||
|
||||
// invalid forwarded IP is ignored
|
||||
array(array('88.88.88.88'), '127.0.0.1', 'unknown,88.88.88.88', array('127.0.0.1')),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -139,15 +139,19 @@ class SomeUser implements UserInterface
|
||||
public function getRoles()
|
||||
{
|
||||
}
|
||||
|
||||
public function getPassword()
|
||||
{
|
||||
}
|
||||
|
||||
public function getSalt()
|
||||
{
|
||||
}
|
||||
|
||||
public function getUsername()
|
||||
{
|
||||
}
|
||||
|
||||
public function eraseCredentials()
|
||||
{
|
||||
}
|
||||
|
@ -94,6 +94,7 @@ class AnnotationLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$this->assertEquals($expected_parent, $parent_metadata);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test MetaData merge with parent annotation.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user