Merge branch '2.3' into 2.4
* 2.3: Check headers sent before sending PHP response Fixed ACE domain checks on UrlValidator (#10031) handle array root element
This commit is contained in:
commit
af6d11c9c6
@ -91,9 +91,11 @@ class ExceptionHandler
|
|||||||
$exception = FlattenException::create($exception);
|
$exception = FlattenException::create($exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
header(sprintf('HTTP/1.0 %s', $exception->getStatusCode()));
|
if (!headers_sent()) {
|
||||||
foreach ($exception->getHeaders() as $name => $value) {
|
header(sprintf('HTTP/1.0 %s', $exception->getStatusCode()));
|
||||||
header($name.': '.$value, false);
|
foreach ($exception->getHeaders() as $name => $value) {
|
||||||
|
header($name.': '.$value, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
echo $this->decorate($this->getContent($exception), $this->getStylesheet($exception));
|
echo $this->decorate($this->getContent($exception), $this->getStylesheet($exception));
|
||||||
|
@ -95,7 +95,14 @@ class ConstraintViolation implements ConstraintViolationInterface
|
|||||||
*/
|
*/
|
||||||
public function __toString()
|
public function __toString()
|
||||||
{
|
{
|
||||||
$class = (string) (is_object($this->root) ? get_class($this->root) : $this->root);
|
if (is_object($this->root)) {
|
||||||
|
$class = get_class($this->root);
|
||||||
|
} elseif (is_array($this->root)) {
|
||||||
|
$class = "Array";
|
||||||
|
} else {
|
||||||
|
$class = (string) $this->root;
|
||||||
|
}
|
||||||
|
|
||||||
$propertyPath = (string) $this->propertyPath;
|
$propertyPath = (string) $this->propertyPath;
|
||||||
$code = $this->code;
|
$code = $this->code;
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ class UrlValidator extends ConstraintValidator
|
|||||||
const PATTERN = '~^
|
const PATTERN = '~^
|
||||||
(%s):// # protocol
|
(%s):// # protocol
|
||||||
(
|
(
|
||||||
([\pL\pN\pS-]+\.)+[\pL]+ # a domain name
|
([\pL\pN\pS-]+\.)+([\pL]|xn\-\-[\pL\pN-]+)+ # a domain name
|
||||||
| # or
|
| # or
|
||||||
\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} # a IP address
|
\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} # a IP address
|
||||||
| # or
|
| # or
|
||||||
|
@ -33,4 +33,23 @@ EOF;
|
|||||||
|
|
||||||
$this->assertSame($expected, (string) $violation);
|
$this->assertSame($expected, (string) $violation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testToStringHandlesArrayRoots()
|
||||||
|
{
|
||||||
|
$violation = new ConstraintViolation(
|
||||||
|
'42 cannot be used here',
|
||||||
|
'this is the message template',
|
||||||
|
array(),
|
||||||
|
array('some_value' => 42),
|
||||||
|
'some_value',
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
|
$expected = <<<EOF
|
||||||
|
Array.some_value:
|
||||||
|
42 cannot be used here
|
||||||
|
EOF;
|
||||||
|
|
||||||
|
$this->assertSame($expected, (string) $violation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,15 +91,28 @@ class UrlValidatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
array('http://[::1]:80/'),
|
array('http://[::1]:80/'),
|
||||||
array('http://[1:2:3::4:5:6:7]/'),
|
array('http://[1:2:3::4:5:6:7]/'),
|
||||||
array('http://sãopaulo.com/'),
|
array('http://sãopaulo.com/'),
|
||||||
|
array('http://xn--sopaulo-xwa.com/'),
|
||||||
array('http://sãopaulo.com.br/'),
|
array('http://sãopaulo.com.br/'),
|
||||||
|
array('http://xn--sopaulo-xwa.com.br/'),
|
||||||
array('http://пример.испытание/'),
|
array('http://пример.испытание/'),
|
||||||
|
array('http://xn--e1afmkfd.xn--80akhbyknj4f/'),
|
||||||
array('http://مثال.إختبار/'),
|
array('http://مثال.إختبار/'),
|
||||||
|
array('http://xn--mgbh0fb.xn--kgbechtv/'),
|
||||||
array('http://例子.测试/'),
|
array('http://例子.测试/'),
|
||||||
|
array('http://xn--fsqu00a.xn--0zwm56d/'),
|
||||||
array('http://例子.測試/'),
|
array('http://例子.測試/'),
|
||||||
|
array('http://xn--fsqu00a.xn--g6w251d/'),
|
||||||
array('http://例え.テスト/'),
|
array('http://例え.テスト/'),
|
||||||
|
array('http://xn--r8jz45g.xn--zckzah/'),
|
||||||
array('http://مثال.آزمایشی/'),
|
array('http://مثال.آزمایشی/'),
|
||||||
|
array('http://xn--mgbh0fb.xn--hgbk6aj7f53bba/'),
|
||||||
array('http://실례.테스트/'),
|
array('http://실례.테스트/'),
|
||||||
|
array('http://xn--9n2bp8q.xn--9t4b11yi5a/'),
|
||||||
array('http://العربية.idn.icann.org/'),
|
array('http://العربية.idn.icann.org/'),
|
||||||
|
array('http://xn--ogb.idn.icann.org/'),
|
||||||
|
array('http://xn--e1afmkfd.xn--80akhbyknj4f.xn--e1afmkfd/'),
|
||||||
|
array('http://xn--espaa-rta.xn--ca-ol-fsay5a/'),
|
||||||
|
array('http://xn--d1abbgf6aiiy.xn--p1ai/'),
|
||||||
array('http://☎.com/'),
|
array('http://☎.com/'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user