Merge branch '2.7' into 2.8

* 2.7:
  use brace-style regex delimiters
  Fixed typo RecursiveIterator -> RecursiveIteratorIterator
  [Validator] make phpdoc of ObjectInitializerInterface interface more accurate
This commit is contained in:
Fabien Potencier 2018-05-07 08:57:27 +02:00
commit c2cccaf9c4
4 changed files with 16 additions and 5 deletions

View File

@ -17,7 +17,7 @@ namespace Symfony\Component\Form\Util;
* Contrary to \ArrayIterator, this iterator recognizes changes in the original * Contrary to \ArrayIterator, this iterator recognizes changes in the original
* array during iteration. * array during iteration.
* *
* You can wrap the iterator into a {@link \RecursiveIterator} in order to * You can wrap the iterator into a {@link \RecursiveIteratorIterator} in order to
* enter any child form that inherits its parent's data and iterate the children * enter any child form that inherits its parent's data and iterate the children
* of that form as well. * of that form as well.
* *

View File

@ -590,7 +590,7 @@ class Request
public static function setTrustedHosts(array $hostPatterns) public static function setTrustedHosts(array $hostPatterns)
{ {
self::$trustedHostPatterns = array_map(function ($hostPattern) { self::$trustedHostPatterns = array_map(function ($hostPattern) {
return sprintf('#%s#i', $hostPattern); return sprintf('{%s}i', $hostPattern);
}, $hostPatterns); }, $hostPatterns);
// we need to reset trusted hosts on trusted host patterns change // we need to reset trusted hosts on trusted host patterns change
self::$trustedHosts = array(); self::$trustedHosts = array();

View File

@ -18,6 +18,11 @@ use Symfony\Component\HttpFoundation\Request;
class RequestTest extends TestCase class RequestTest extends TestCase
{ {
protected function tearDown()
{
Request::setTrustedHosts(array());
}
public function testInitialize() public function testInitialize()
{ {
$request = new Request(); $request = new Request();
@ -1920,9 +1925,15 @@ class RequestTest extends TestCase
$request->headers->set('host', 'subdomain.trusted.com'); $request->headers->set('host', 'subdomain.trusted.com');
$this->assertEquals('subdomain.trusted.com', $request->getHost()); $this->assertEquals('subdomain.trusted.com', $request->getHost());
}
// reset request for following tests public function testSetTrustedHostsDoesNotBreakOnSpecialCharacters()
Request::setTrustedHosts(array()); {
Request::setTrustedHosts(array('localhost(\.local){0,1}#,example.com', 'localhost'));
$request = Request::create('/');
$request->headers->set('host', 'localhost');
$this->assertSame('localhost', $request->getHost());
} }
public function testFactory() public function testFactory()

View File

@ -15,7 +15,7 @@ namespace Symfony\Component\Validator;
* Prepares an object for validation. * Prepares an object for validation.
* *
* Concrete implementations of this interface are used by {@link ValidationVisitorInterface} * Concrete implementations of this interface are used by {@link ValidationVisitorInterface}
* to initialize objects just before validating them. * and {@link Validator\ContextualValidatorInterface} to initialize objects just before validating them.
* *
* @author Fabien Potencier <fabien@symfony.com> * @author Fabien Potencier <fabien@symfony.com>
* @author Bernhard Schussek <bschussek@gmail.com> * @author Bernhard Schussek <bschussek@gmail.com>