Skip to content

Commit 4a211d8

Browse files
Merge branch '2.7' into 2.8
* 2.7: fixed wrong description in a phpdoc 19 digits VISA card numbers are valid [HttpKernel] Fixed test name [Debug] prevent infinite loop with faulty exception handlers Add the missing `enabled` session attribute [HttpKernel] Turn bad hosts into 400 instead of 500
2 parents eca17ec + cbf73c6 commit 4a211d8

File tree

7 files changed

+36
-5
lines changed

7 files changed

+36
-5
lines changed

src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
</xsd:complexType>
106106

107107
<xsd:complexType name="session">
108+
<xsd:attribute name="enabled" type="xsd:boolean" />
108109
<xsd:attribute name="storage-id" type="xsd:string" />
109110
<xsd:attribute name="handler-id" type="xsd:string" />
110111
<xsd:attribute name="name" type="xsd:string" />

src/Symfony/Component/Console/Input/StringInput.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class StringInput extends ArgvInput
2828
const REGEX_QUOTED_STRING = '(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\')';
2929

3030
/**
31-
* @param string $input An array of parameters from the CLI (in the argv format)
31+
* @param string $input A string representing the parameters from the CLI
3232
* @param InputDefinition $definition A InputDefinition instance
3333
*
3434
* @deprecated The second argument is deprecated as it does not work (will be removed in 3.0), use 'bind' method instead

src/Symfony/Component/Debug/ErrorHandler.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,8 @@ public static function handleFatalError(array $error = null)
631631

632632
$handler = self::$reservedMemory = null;
633633
$handlers = array();
634+
$previousHandler = null;
635+
$sameHandlerLimit = 10;
634636

635637
while (!is_array($handler) || !$handler[0] instanceof self) {
636638
$handler = set_exception_handler('var_dump');
@@ -640,7 +642,14 @@ public static function handleFatalError(array $error = null)
640642
break;
641643
}
642644
restore_exception_handler();
643-
array_unshift($handlers, $handler);
645+
646+
if ($handler !== $previousHandler) {
647+
array_unshift($handlers, $handler);
648+
$previousHandler = $handler;
649+
} elseif (0 === --$sameHandlerLimit) {
650+
$handler = null;
651+
break;
652+
}
644653
}
645654
foreach ($handlers as $h) {
646655
set_exception_handler($h);

src/Symfony/Component/HttpKernel/EventListener/RouterListener.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
1616
use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
1717
use Symfony\Component\HttpKernel\KernelEvents;
18+
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
1819
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
1920
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
2021
use Symfony\Component\HttpFoundation\RequestStack;
@@ -113,7 +114,11 @@ public function setRequest(Request $request = null)
113114
private function setCurrentRequest(Request $request = null)
114115
{
115116
if (null !== $request && $this->request !== $request) {
116-
$this->context->fromRequest($request);
117+
try {
118+
$this->context->fromRequest($request);
119+
} catch (\UnexpectedValueException $e) {
120+
throw new BadRequestHttpException($e->getMessage(), $e, $e->getCode());
121+
}
117122
}
118123

119124
$this->request = $request;

src/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,19 @@ public function getLoggingParameterData()
155155
array(array(), 'Matched route "n/a".'),
156156
);
157157
}
158+
159+
/**
160+
* @expectedException \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
161+
*/
162+
public function testRequestWithBadHost()
163+
{
164+
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
165+
$request = Request::create('http://bad host %22/');
166+
$event = new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST);
167+
168+
$requestMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock();
169+
170+
$listener = new RouterListener($requestMatcher, new RequestContext(), null, $this->requestStack);
171+
$listener->onKernelRequest($event);
172+
}
158173
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ class CardSchemeValidator extends ConstraintValidator
7979
'/^5[1-5][0-9]{14}$/',
8080
'/^2(22[1-9][0-9]{12}|2[3-9][0-9]{13}|[3-6][0-9]{14}|7[0-1][0-9]{13}|720[0-9]{12})$/',
8181
),
82-
// All Visa card numbers start with a 4. New cards have 16 digits. Old cards have 13.
82+
// All Visa card numbers start with a 4 and have a length of 13, 16, or 19 digits.
8383
'VISA' => array(
84-
'/^4([0-9]{12}|[0-9]{15})$/',
84+
'/^4([0-9]{12}|[0-9]{15}|[0-9]{18})$/',
8585
),
8686
);
8787

src/Symfony/Component/Validator/Tests/Constraints/CardSchemeValidatorTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ public function getValidNumbers()
111111
array('VISA', '4111111111111111'),
112112
array('VISA', '4012888888881881'),
113113
array('VISA', '4222222222222'),
114+
array('VISA', '4917610000000000003'),
114115
array(array('AMEX', 'VISA'), '4111111111111111'),
115116
array(array('AMEX', 'VISA'), '378282246310005'),
116117
array(array('JCB', 'MASTERCARD'), '5105105105105100'),

0 commit comments

Comments
 (0)