Skip to content

Commit 6aec217

Browse files
Merge branch '3.4' into 4.2
* 3.4: Revert "bug #30423 [Security] Rework firewall's access denied rule (dimabory)" [FrameworkBundle] minor: remove a typo from changelog [VarDumper][Ldap] relax some locally failing tests [Validator] #30192 Added the missing translations for the Tagalog ("tl") locale. Make MimeTypeExtensionGuesser case insensitive
2 parents 3fd01ab + 82f003e commit 6aec217

File tree

9 files changed

+87
-60
lines changed

9 files changed

+87
-60
lines changed

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ CHANGELOG
134134
The default value will be `state_machine` in Symfony 4.0.
135135
* Deprecated the `CompilerDebugDumpPass` class
136136
* Deprecated the "framework.trusted_proxies" configuration option and the corresponding "kernel.trusted_proxies" parameter
137-
* Added a new new version strategy option called json_manifest_path
137+
* Added a new version strategy option called "json_manifest_path"
138138
that allows you to use the `JsonManifestVersionStrategy`.
139139
* Added `Symfony\Bundle\FrameworkBundle\Controller\AbstractController`. It provides
140140
the same helpers as the `Controller` class, but does not allow accessing the dependency

src/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeExtensionGuesser.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,12 @@ class MimeTypeExtensionGuesser implements ExtensionGuesserInterface
808808
*/
809809
public function guess($mimeType)
810810
{
811-
return isset($this->defaultExtensions[$mimeType]) ? $this->defaultExtensions[$mimeType] : null;
811+
if (isset($this->defaultExtensions[$mimeType])) {
812+
return $this->defaultExtensions[$mimeType];
813+
}
814+
815+
$lcMimeType = strtolower($mimeType);
816+
817+
return isset($this->defaultExtensions[$lcMimeType]) ? $this->defaultExtensions[$lcMimeType] : null;
812818
}
813819
}

src/Symfony/Component/HttpFoundation/Tests/File/UploadedFileTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,18 @@ public function testGuessClientExtensionWithIncorrectMimeType()
9494
$this->assertEquals('jpeg', $file->guessClientExtension());
9595
}
9696

97+
public function testCaseSensitiveMimeType()
98+
{
99+
$file = new UploadedFile(
100+
__DIR__.'/Fixtures/case-sensitive-mime-type.xlsm',
101+
'test.xlsm',
102+
'application/vnd.ms-excel.sheet.macroEnabled.12',
103+
null
104+
);
105+
106+
$this->assertEquals('xlsm', $file->guessClientExtension());
107+
}
108+
97109
public function testErrorIsOkByDefault()
98110
{
99111
$file = new UploadedFile(

src/Symfony/Component/Ldap/Tests/LdapTestCase.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ class LdapTestCase extends TestCase
88
{
99
protected function getLdapConfig()
1010
{
11+
$h = @ldap_connect(getenv('LDAP_HOST'), getenv('LDAP_PORT'));
12+
13+
if (!$h || !@ldap_bind($h)) {
14+
$this->markTestSkipped('No server is listening on LDAP_HOST:LDAP_PORT');
15+
}
16+
17+
ldap_close($h);
18+
1119
return [
1220
'host' => getenv('LDAP_HOST'),
1321
'port' => getenv('LDAP_PORT'),

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ private function handleAccessDeniedException(GetResponseForExceptionEvent $event
131131
} catch (\Exception $e) {
132132
$event->setException($e);
133133
}
134+
135+
return;
134136
}
135137

136138
if (null !== $this->logger) {
@@ -148,7 +150,7 @@ private function handleAccessDeniedException(GetResponseForExceptionEvent $event
148150
$subRequest = $this->httpUtils->createRequest($event->getRequest(), $this->errorPage);
149151
$subRequest->attributes->set(Security::ACCESS_DENIED_ERROR, $exception);
150152

151-
$event->setResponse($event->getKernel()->handle($subRequest, HttpKernelInterface::SUB_REQUEST));
153+
$event->setResponse($event->getKernel()->handle($subRequest, HttpKernelInterface::SUB_REQUEST, true));
152154
$event->allowCustomResponseCode();
153155
}
154156
} catch (\Exception $e) {

src/Symfony/Component/Security/Http/Tests/Firewall/ExceptionListenerTest.php

Lines changed: 7 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,10 @@ public function testAccessDeniedExceptionFullFledgedAndWithAccessDeniedHandlerAn
130130
{
131131
$event = $this->createEvent($exception);
132132

133-
$listener = $this->createExceptionListener(null, $this->createTrustResolver(true), null, null, null, $this->createCustomAccessDeniedHandler(new Response('error')));
133+
$accessDeniedHandler = $this->getMockBuilder('Symfony\Component\Security\Http\Authorization\AccessDeniedHandlerInterface')->getMock();
134+
$accessDeniedHandler->expects($this->once())->method('handle')->will($this->returnValue(new Response('error')));
134135

136+
$listener = $this->createExceptionListener(null, $this->createTrustResolver(true), null, null, null, $accessDeniedHandler);
135137
$listener->onKernelException($event);
136138

137139
$this->assertEquals('error', $event->getResponse()->getContent());
@@ -145,48 +147,13 @@ public function testAccessDeniedExceptionNotFullFledged(\Exception $exception, \
145147
{
146148
$event = $this->createEvent($exception);
147149

148-
$listener = $this->createExceptionListener($this->createTokenStorage(), $this->createTrustResolver(false), null, $this->createEntryPoint());
149-
$listener->onKernelException($event);
150-
151-
$this->assertEquals('OK', $event->getResponse()->getContent());
152-
$this->assertSame(null === $eventException ? $exception : $eventException, $event->getException()->getPrevious());
153-
}
154-
155-
/**
156-
* @dataProvider getAccessDeniedExceptionProvider
157-
*/
158-
public function testAccessDeniedExceptionNotFullFledgedAndWithAccessDeniedHandlerAndWithoutErrorPage(\Exception $exception, \Exception $eventException = null)
159-
{
160-
$event = $this->createEvent($exception);
161-
162-
$listener = $this->createExceptionListener($this->createTokenStorage(), $this->createTrustResolver(false), null, $this->createEntryPoint(), null, $this->createCustomAccessDeniedHandler(new Response('denied', 403)));
163-
$listener->onKernelException($event);
164-
165-
$this->assertEquals('denied', $event->getResponse()->getContent());
166-
$this->assertEquals(403, $event->getResponse()->getStatusCode());
167-
$this->assertSame(null === $eventException ? $exception : $eventException, $event->getException()->getPrevious());
168-
}
169-
170-
/**
171-
* @dataProvider getAccessDeniedExceptionProvider
172-
*/
173-
public function testAccessDeniedExceptionNotFullFledgedAndWithoutAccessDeniedHandlerAndWithErrorPage(\Exception $exception, \Exception $eventException = null)
174-
{
175-
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
176-
$kernel->expects($this->once())->method('handle')->will($this->returnValue(new Response('Unauthorized', 401)));
177-
178-
$event = $this->createEvent($exception, $kernel);
179-
180-
$httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock();
181-
$httpUtils->expects($this->once())->method('createRequest')->will($this->returnValue(Request::create('/error')));
150+
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
151+
$tokenStorage->expects($this->once())->method('getToken')->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()));
182152

183-
$listener = $this->createExceptionListener($this->createTokenStorage(), $this->createTrustResolver(true), $httpUtils, null, '/error');
153+
$listener = $this->createExceptionListener($tokenStorage, $this->createTrustResolver(false), null, $this->createEntryPoint());
184154
$listener->onKernelException($event);
185155

186-
$this->assertTrue($event->isAllowingCustomResponseCode());
187-
188-
$this->assertEquals('Unauthorized', $event->getResponse()->getContent());
189-
$this->assertEquals(401, $event->getResponse()->getStatusCode());
156+
$this->assertEquals('OK', $event->getResponse()->getContent());
190157
$this->assertSame(null === $eventException ? $exception : $eventException, $event->getException()->getPrevious());
191158
}
192159

@@ -201,22 +168,6 @@ public function getAccessDeniedExceptionProvider()
201168
];
202169
}
203170

204-
private function createTokenStorage()
205-
{
206-
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
207-
$tokenStorage->expects($this->once())->method('getToken')->will($this->returnValue($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()));
208-
209-
return $tokenStorage;
210-
}
211-
212-
private function createCustomAccessDeniedHandler(Response $response)
213-
{
214-
$accessDeniedHandler = $this->getMockBuilder('Symfony\Component\Security\Http\Authorization\AccessDeniedHandlerInterface')->getMock();
215-
$accessDeniedHandler->expects($this->once())->method('handle')->will($this->returnValue($response));
216-
217-
return $accessDeniedHandler;
218-
}
219-
220171
private function createEntryPoint(Response $response = null)
221172
{
222173
$entryPoint = $this->getMockBuilder('Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface')->getMock();

src/Symfony/Component/Validator/Resources/translations/validators.tl.xlf

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,54 @@
314314
<source>This is not a valid Business Identifier Code (BIC).</source>
315315
<target>Ito ay hindi isang balidong Business Identifier Code (BIC).</target>
316316
</trans-unit>
317+
<trans-unit id="82">
318+
<source>Error</source>
319+
<target>Error</target>
320+
</trans-unit>
321+
<trans-unit id="83">
322+
<source>This is not a valid UUID.</source>
323+
<target>Ito ay hindi wastong UUID.</target>
324+
</trans-unit>
325+
<trans-unit id="84">
326+
<source>This value should be a multiple of {{ compared_value }}.</source>
327+
<target>Ang halagang ito ay dapat multiple ng {{ compared_value }}.</target>
328+
</trans-unit>
329+
<trans-unit id="85">
330+
<source>This Business Identifier Code (BIC) is not associated with IBAN {{ iban }}.</source>
331+
<target>Ang Business Identifier Code (BIC) na ito ay walang kaugnayan sa IBAN {{ iban }}.</target>
332+
</trans-unit>
333+
<trans-unit id="86">
334+
<source>This value should be valid JSON.</source>
335+
<target>Ang halagang ito ay dapat naka wastong JSON.</target>
336+
</trans-unit>
337+
<trans-unit id="87">
338+
<source>This collection should contain only unique elements.</source>
339+
<target>Ang mga elemento ng koleksyong ito ay dapat magkakaiba.</target>
340+
</trans-unit>
341+
<trans-unit id="88">
342+
<source>This value should be positive.</source>
343+
<target>Ang halagang ito ay dapat positibo.</target>
344+
</trans-unit>
345+
<trans-unit id="89">
346+
<source>This value should be either positive or zero.</source>
347+
<target>Ang halagang ito ay dapat positibo o zero.</target>
348+
</trans-unit>
349+
<trans-unit id="90">
350+
<source>This value should be negative.</source>
351+
<target>Ang halagang ito ay dapat negatibo.</target>
352+
</trans-unit>
353+
<trans-unit id="91">
354+
<source>This value should be either negative or zero.</source>
355+
<target>Ang halagang ito ay dapat negatibo o zero.</target>
356+
</trans-unit>
357+
<trans-unit id="92">
358+
<source>This value is not a valid timezone.</source>
359+
<target>Ang halagang ito ay hindi wastong timezone.</target>
360+
</trans-unit>
361+
<trans-unit id="93">
362+
<source>This password has been leaked in a data breach, it must not be used. Please use another password.</source>
363+
<target>Naikalat ang password na ito sa isang data breach at hindi na dapat gamitin. Mangyaring gumamit ng ibang pang password.</target>
364+
</trans-unit>
317365
</body>
318366
</file>
319367
</xliff>

src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function testReflectionCaster()
3737
%A]
3838
constants: array:3 [
3939
"IS_IMPLICIT_ABSTRACT" => 16
40-
"IS_EXPLICIT_ABSTRACT" => 32
40+
"IS_EXPLICIT_ABSTRACT" => %d
4141
"IS_FINAL" => %d
4242
]
4343
properties: array:%d [

0 commit comments

Comments
 (0)