Skip to content

Commit 684975d

Browse files
Merge branch '2.7' into 2.8
* 2.7: Github template: Remove EOM 3.2 from branch suggestion [Security] Fix security.interactive_login event const doc block Avoid infinite loops when profiler data is malformed [HttpFoundation] Generate safe fallback filename for wrongly encoded filename
2 parents 2807709 + 695266f commit 684975d

File tree

5 files changed

+30
-8
lines changed

5 files changed

+30
-8
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
| Q | A
22
| ------------- | ---
3-
| Branch? | 3.4 or master / 2.7, 2.8, 3.2 or 3.3 <!-- see comment below -->
3+
| Branch? | 3.4 or master / 2.7, 2.8 or 3.3 <!-- see comment below -->
44
| Bug fix? | yes/no
55
| New feature? | yes/no <!-- don't forget updating src/**/CHANGELOG.md files -->
66
| BC breaks? | yes/no

src/Symfony/Component/HttpFoundation/BinaryFileResponse.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public function setAutoEtag()
150150
* Sets the Content-Disposition header with the given filename.
151151
*
152152
* @param string $disposition ResponseHeaderBag::DISPOSITION_INLINE or ResponseHeaderBag::DISPOSITION_ATTACHMENT
153-
* @param string $filename Optionally use this filename instead of the real name of the file
153+
* @param string $filename Optionally use this UTF-8 encoded filename instead of the real name of the file
154154
* @param string $filenameFallback A fallback filename, containing only ASCII characters. Defaults to an automatically encoded filename
155155
*
156156
* @return $this
@@ -162,7 +162,7 @@ public function setContentDisposition($disposition, $filename = '', $filenameFal
162162
}
163163

164164
if ('' === $filenameFallback && (!preg_match('/^[\x20-\x7e]*$/', $filename) || false !== strpos($filename, '%'))) {
165-
$encoding = mb_detect_encoding($filename, null, true);
165+
$encoding = mb_detect_encoding($filename, null, true) ?: '8bit';
166166

167167
for ($i = 0, $filenameLength = mb_strlen($filename, $encoding); $i < $filenameLength; ++$i) {
168168
$char = mb_substr($filename, $i, 1, $encoding);

src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,17 @@ public function testSetContentDispositionGeneratesSafeFallbackFilename()
6868
$this->assertSame('attachment; filename="f__.html"; filename*=utf-8\'\'f%C3%B6%C3%B6.html', $response->headers->get('Content-Disposition'));
6969
}
7070

71+
public function testSetContentDispositionGeneratesSafeFallbackFilenameForWronglyEncodedFilename()
72+
{
73+
$response = new BinaryFileResponse(__FILE__);
74+
75+
$iso88591EncodedFilename = utf8_decode('föö.html');
76+
$response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $iso88591EncodedFilename);
77+
78+
// the parameter filename* is invalid in this case (rawurldecode('f%F6%F6') does not provide a UTF-8 string but an ISO-8859-1 encoded one)
79+
$this->assertSame('attachment; filename="f__.html"; filename*=utf-8\'\'f%F6%F6.html', $response->headers->get('Content-Disposition'));
80+
}
81+
7182
/**
7283
* @dataProvider provideRanges
7384
*/

src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,19 @@ public function write(Profile $profile)
144144
}
145145
}
146146

147+
$profileToken = $profile->getToken();
148+
// when there are errors in sub-requests, the parent and/or children tokens
149+
// may equal the profile token, resulting in infinite loops
150+
$parentToken = $profile->getParentToken() !== $profileToken ? $profile->getParentToken() : null;
151+
$childrenToken = array_filter(array_map(function ($p) use ($profileToken) {
152+
return $profileToken !== $p->getToken() ? $p->getToken() : null;
153+
}, $profile->getChildren()));
154+
147155
// Store profile
148156
$data = array(
149-
'token' => $profile->getToken(),
150-
'parent' => $profile->getParentToken(),
151-
'children' => array_map(function ($p) { return $p->getToken(); }, $profile->getChildren()),
157+
'token' => $profileToken,
158+
'parent' => $parentToken,
159+
'children' => $childrenToken,
152160
'data' => $profile->getCollectors(),
153161
'ip' => $profile->getIp(),
154162
'method' => $profile->getMethod(),

src/Symfony/Component/Security/Http/SecurityEvents.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@
1414
final class SecurityEvents
1515
{
1616
/**
17-
* The INTERACTIVE_LOGIN event occurs after a user is logged in
18-
* interactively for authentication based on http, cookies or X509.
17+
* The INTERACTIVE_LOGIN event occurs after a user has actively logged
18+
* into your website. It is important to distinguish this action from
19+
* non-interactive authentication methods, such as:
20+
* - authentication based on your session.
21+
* - authentication using a HTTP basic or HTTP digest header.
1922
*
2023
* The event listener method receives a
2124
* Symfony\Component\Security\Http\Event\InteractiveLoginEvent instance.

0 commit comments

Comments
 (0)