Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfd5a2d0

Browse files
committed
Merge branch '2.4'
* 2.4: [Security] simplified some unit tests [Security] made code easier to understand, added some missing unit tests [DependencyInjection] fixed InlineServiceDefinitionsPass to not inline a service if it's part of the current definition (to avoid an infinite loop) [DomCrawler] Fixed creating form objects from form nodes. disabled php.ini changes when using HHVM in .travis.yml [Process] fixed HHVM support Add support for HHVM in the getting of the PHP executable [Security] fixed error 500 instead of 403 if previous exception is provided to AccessDeniedException
2 parents7d80045 +206c610 commitfd5a2d0

File tree

8 files changed

+279
-62
lines changed

8 files changed

+279
-62
lines changed

‎.travis.yml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ services: mongodb
1515

1616
before_script:
1717
-sudo apt-get install parallel
18-
-sh -c 'if [ $(php -r "echo (int) defined("HHVM_VERSION");") -eq 0 ]; then echo "" >> "~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini"; fi;'
19-
-echo"extension = mongo.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
18+
-sh -c 'if [ $(php -r "echo (int) defined('HHVM_VERSION');") -eq 0 ]; then echo "" >> "~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini"; fi;'
19+
-sh -c 'if [ $(php -r "echo(int) defined('HHVM_VERSION');") -eq 0 ]; then echo "extension = mongo.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;'
2020
-sh -c 'if [ $(php -r "echo PHP_MINOR_VERSION;") -le 4 ]; then echo "extension = apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;'
21-
-echo"extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
22-
-echo"extension = memcache.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
21+
-sh -c 'if [ $(php -r "echo(int) defined('HHVM_VERSION');") -eq 0 ]; then echo "extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;'
22+
-sh -c 'if [ $(php -r "echo(int) defined('HHVM_VERSION');") -eq 0 ]; then echo "extension = memcache.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;'
2323
-COMPOSER_ROOT_VERSION=dev-master composer --prefer-source --dev install
2424

2525
script:

‎src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ private function isInlineableDefinition(ContainerBuilder $container, $id, Defini
130130
returntrue;
131131
}
132132

133+
if ($this->currentId ==$id) {
134+
returnfalse;
135+
}
136+
133137
$ids =array();
134138
foreach ($this->graph->getNode($id)->getInEdges()as$edge) {
135139
$ids[] =$edge->getSourceNode()->getId();

‎src/Symfony/Component/DependencyInjection/Tests/Compiler/InlineServiceDefinitionsPassTest.php‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,21 @@ public function testProcessDoesNotInlineWhenServiceIsPrivateButLazy()
144144
$this->assertSame($ref,$arguments[0]);
145145
}
146146

147+
publicfunctiontestProcessDoesNotInlineWhenServiceReferencesItself()
148+
{
149+
$container =newContainerBuilder();
150+
$container
151+
->register('foo')
152+
->setPublic(false)
153+
->addMethodCall('foo',array($ref =newReference('foo')))
154+
;
155+
156+
$this->process($container);
157+
158+
$calls =$container->getDefinition('foo')->getMethodCalls();
159+
$this->assertSame($ref,$calls[0][1][0]);
160+
}
161+
147162
protectedfunctionprocess(ContainerBuilder$container)
148163
{
149164
$repeatedPass =newRepeatedPass(array(newAnalyzeServiceReferencesPass(),newInlineServiceDefinitionsPass()));

‎src/Symfony/Component/DomCrawler/Form.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ private function initialize()
399399
$root =$document->appendChild($document->createElement('_root'));
400400

401401
// add submitted button if it has a valid name
402-
if ($this->button->hasAttribute('name') &&$this->button->getAttribute('name')) {
402+
if ('form' !==$this->button->nodeName &&$this->button->hasAttribute('name') &&$this->button->getAttribute('name')) {
403403
$this->set(newField\InputFormField($document->importNode($this->button,true)));
404404
}
405405

‎src/Symfony/Component/DomCrawler/Tests/FormTest.php‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,16 @@ public function testGetFormNode()
273273
$this->assertSame($dom->getElementsByTagName('form')->item(0),$form->getFormNode(),'->getFormNode() returns the form node associated with this form');
274274
}
275275

276+
publicfunctiontestGetFormNodeFromNamedForm()
277+
{
278+
$dom =new \DOMDocument();
279+
$dom->loadHTML('<html><form name="my_form"><input type="submit" /></form></html>');
280+
281+
$form =newForm($dom->getElementsByTagName('form')->item(0),'http://example.com');
282+
283+
$this->assertSame($dom->getElementsByTagName('form')->item(0),$form->getFormNode(),'->getFormNode() returns the form node associated with this form');
284+
}
285+
276286
publicfunctiontestGetMethod()
277287
{
278288
$form =$this->createForm('<form><input type="submit" /></form>');

‎src/Symfony/Component/Process/PhpExecutableFinder.php‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ public function __construct()
3333
*/
3434
publicfunctionfind()
3535
{
36+
// HHVM support
37+
if (defined('HHVM_VERSION') &&false !==$hhvm =getenv('PHP_BINARY')) {
38+
return$hhvm;
39+
}
40+
3641
// PHP_BINARY return the current sapi executable
3742
if (defined('PHP_BINARY') &&PHP_BINARY && ('cli' ===PHP_SAPI) &&is_file(PHP_BINARY)) {
3843
returnPHP_BINARY;

‎src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php‎

Lines changed: 56 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -87,84 +87,83 @@ public function unregister(EventDispatcherInterface $dispatcher)
8787
publicfunctiononKernelException(GetResponseForExceptionEvent$event)
8888
{
8989
$exception =$event->getException();
90-
$request =$event->getRequest();
90+
do {
91+
if ($exceptioninstanceof AuthenticationException) {
92+
return$this->handleAuthenticationException($event,$exception);
93+
}elseif ($exceptioninstanceof AccessDeniedException) {
94+
return$this->handleAccessDeniedException($event,$exception);
95+
}elseif ($exceptioninstanceof LogoutException) {
96+
return$this->handleLogoutException($event,$exception);
97+
}
98+
}while (null !==$exception =$exception->getPrevious());
99+
}
91100

92-
// determine the actual cause for the exception
93-
while (null !==$previous =$exception->getPrevious()) {
94-
$exception =$previous;
101+
privatefunctionhandleAuthenticationException(GetResponseForExceptionEvent$event,AuthenticationException$exception)
102+
{
103+
if (null !==$this->logger) {
104+
$this->logger->info(sprintf('Authentication exception occurred; redirecting to authentication entry point (%s)',$exception->getMessage()));
95105
}
96106

97-
if ($exceptioninstanceof AuthenticationException) {
107+
try {
108+
$event->setResponse($this->startAuthentication($event->getRequest(),$exception));
109+
}catch (\Exception$e) {
110+
$event->setException($e);
111+
}
112+
}
113+
114+
privatefunctionhandleAccessDeniedException(GetResponseForExceptionEvent$event,AccessDeniedException$exception)
115+
{
116+
$event->setException(newAccessDeniedHttpException($exception->getMessage(),$exception));
117+
118+
$token =$this->context->getToken();
119+
if (!$this->authenticationTrustResolver->isFullFledged($token)) {
98120
if (null !==$this->logger) {
99-
$this->logger->info(sprintf('Authentication exception occurred; redirecting to authentication entry point (%s)',$exception->getMessage()));
121+
$this->logger->debug(sprintf('Access is denied (user is not fully authenticated) by "%s" at line %s; redirecting to authentication entry point',$exception->getFile(),$exception->getLine()));
100122
}
101123

102124
try {
103-
$response =$this->startAuthentication($request,$exception);
125+
$insufficientAuthenticationException =newInsufficientAuthenticationException('Full authentication is required to access this resource.',0,$exception);
126+
$insufficientAuthenticationException->setToken($token);
127+
128+
$event->setResponse($this->startAuthentication($event->getRequest(),$insufficientAuthenticationException));
104129
}catch (\Exception$e) {
105130
$event->setException($e);
106-
107-
return;
108131
}
109-
}elseif ($exceptioninstanceof AccessDeniedException) {
110-
$event->setException(newAccessDeniedHttpException($exception->getMessage(),$exception));
111132

112-
$token =$this->context->getToken();
113-
if (!$this->authenticationTrustResolver->isFullFledged($token)) {
114-
if (null !==$this->logger) {
115-
$this->logger->debug(sprintf('Access is denied (user is not fully authenticated) by "%s" at line %s; redirecting to authentication entry point',$exception->getFile(),$exception->getLine()));
116-
}
133+
return;
134+
}
135+
136+
if (null !==$this->logger) {
137+
$this->logger->debug(sprintf('Access is denied (and user is neither anonymous, nor remember-me) by "%s" at line %s',$exception->getFile(),$exception->getLine()));
138+
}
117139

118-
try {
119-
$insufficientAuthenticationException =newInsufficientAuthenticationException('Full authentication is required to access this resource.',0,$exception);
120-
$insufficientAuthenticationException->setToken($token);
121-
$response =$this->startAuthentication($request,$insufficientAuthenticationException);
122-
}catch (\Exception$e) {
123-
$event->setException($e);
140+
try {
141+
if (null !==$this->accessDeniedHandler) {
142+
$response =$this->accessDeniedHandler->handle($event->getRequest(),$exception);
124143

125-
return;
126-
}
127-
}else {
128-
if (null !==$this->logger) {
129-
$this->logger->debug(sprintf('Access is denied (and user is neither anonymous, nor remember-me) by "%s" at line %s',$exception->getFile(),$exception->getLine()));
144+
if ($responseinstanceof Response) {
145+
$event->setResponse($response);
130146
}
147+
}elseif (null !==$this->errorPage) {
148+
$subRequest =$this->httpUtils->createRequest($event->getRequest(),$this->errorPage);
149+
$subRequest->attributes->set(SecurityContextInterface::ACCESS_DENIED_ERROR,$exception);
131150

132-
try {
133-
if (null !==$this->accessDeniedHandler) {
134-
$response =$this->accessDeniedHandler->handle($request,$exception);
135-
136-
if (!$responseinstanceof Response) {
137-
return;
138-
}
139-
}elseif (null !==$this->errorPage) {
140-
$subRequest =$this->httpUtils->createRequest($request,$this->errorPage);
141-
$subRequest->attributes->set(SecurityContextInterface::ACCESS_DENIED_ERROR,$exception);
142-
143-
$response =$event->getKernel()->handle($subRequest, HttpKernelInterface::SUB_REQUEST,true);
144-
}else {
145-
return;
146-
}
147-
}catch (\Exception$e) {
148-
if (null !==$this->logger) {
149-
$this->logger->error(sprintf('Exception thrown when handling an exception (%s: %s)',get_class($e),$e->getMessage()));
150-
}
151-
152-
$event->setException(new \RuntimeException('Exception thrown when handling an exception.',0,$e));
153-
154-
return;
155-
}
151+
$event->setResponse($event->getKernel()->handle($subRequest, HttpKernelInterface::SUB_REQUEST,true));
156152
}
157-
}elseif ($exceptioninstanceof LogoutException) {
153+
}catch (\Exception$e) {
158154
if (null !==$this->logger) {
159-
$this->logger->info(sprintf('Logout exception occurred; wrapping with AccessDeniedHttpException (%s)',$exception->getMessage()));
155+
$this->logger->error(sprintf('Exception thrown when handling an exception (%s: %s)',get_class($e),$e->getMessage()));
160156
}
161157

162-
return;
163-
}else {
164-
return;
158+
$event->setException(new \RuntimeException('Exception thrown when handling an exception.',0,$e));
165159
}
160+
}
166161

167-
$event->setResponse($response);
162+
privatefunctionhandleLogoutException(GetResponseForExceptionEvent$event,LogoutException$exception)
163+
{
164+
if (null !==$this->logger) {
165+
$this->logger->info(sprintf('Logout exception occurred; wrapping with AccessDeniedHttpException (%s)',$exception->getMessage()));
166+
}
168167
}
169168

170169
/**

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp