-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpFoundation] Remove Cache-Control when using https download via IE<9 (fixes #6750) #7153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
[HttpFoundation] Remove Cache-Control when using https download via I…
…E <9 (fixes #6750)
- Loading branch information
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -326,6 +326,48 @@ public function testContentTypeCharset() | |
$this->assertEquals('text/css; charset=UTF-8', $response->headers->get('Content-Type')); | ||
} | ||
|
||
public function testNoCacheControlHeaderOnAttachmentUsingHTTPSAndMSIE() | ||
{ | ||
// Check for HTTPS and IE 8 | ||
$request = new Request(); | ||
$request->server->set('HTTPS', true); | ||
$request->server->set('HTTP_USER_AGENT', 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0)'); | ||
|
||
$response = new Response(); | ||
$response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"'); | ||
$response->prepare($request); | ||
|
||
$this->assertFalse($response->headers->has('Cache-Control')); | ||
|
||
// Check for IE 8 and HTTP | ||
$request->server->set('HTTPS', false); | ||
|
||
$response = new Response('', 200); | ||
$response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"'); | ||
$response->prepare($request); | ||
|
||
$this->assertTrue($response->headers->has('Cache-Control')); | ||
|
||
// Check for non-IE and HTTPS | ||
$request->server->set('HTTPS', true); | ||
$request->server->set('HTTP_USER_AGENT', 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.60 Safari/537.17'); | ||
|
||
$response = new Response('', 200); | ||
$response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"'); | ||
$response->prepare($request); | ||
|
||
$this->assertTrue($response->headers->has('Cache-Control')); | ||
|
||
// Check for non-IE and HTTP | ||
$request->server->set('HTTPS', false); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Plea&se add some tests with the IE9 and 10 user agents as your regex tries to exclude them. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @stof updated tests. |
||
$response = new Response('', 200); | ||
$response->headers->set('Content-Disposition', 'attachment; filename="fname.ext"'); | ||
$response->prepare($request); | ||
|
||
$this->assertTrue($response->headers->has('Cache-Control')); | ||
} | ||
|
||
public function testPrepareDoesNothingIfContentTypeIsSet() | ||
{ | ||
$response = new Response('foo'); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe 8000 this comment to others. Learn more.
You should replace
null === $request->server->get('HTTPS')
by$request->isSecure()
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this regex would match IE 10+ while it does not match IE9. Is it intended ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and btw, using a case-sensitivity modifer inside the regex is useless here. You could simply apply the
i
modifier on the whole regex(/msie [1-8]/i
)