Skip to content

Do not inject web debug toolbar on attachments #18971

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
wants to merge 4 commits into from
Closed

Do not inject web debug toolbar on attachments #18971

wants to merge 4 commits into from

Conversation

peterrehm
Copy link
Contributor

Q A
Branch? 2.7
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #18965
License MIT
Doc PR -

@javiereguiluz
Copy link
Member

👍

Status: reviewed

@xabbuh
Copy link
Member

xabbuh commented Jun 5, 2016

👍

@@ -112,6 +112,11 @@ public function onKernelResponse(FilterResponseEvent $event)
*/
protected function injectToolbar(Response $response, Request $request)
{
// The toolbar shall not be injected if the header enforces a download of the content
if (false !== strpos($response->headers->get('Content-Disposition'), 'attachment')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be moved in the condition starting at line 96 instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

@@ -98,6 +98,7 @@ public function onKernelResponse(FilterResponseEvent $event)
|| $response->isRedirection()
|| ($response->headers->has('Content-Type') && false === strpos($response->headers->get('Content-Type'), 'html'))
|| 'html' !== $request->getRequestFormat()
|| false !== strpos($response->headers->get('Content-Disposition'), 'attachment')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The content-disposition types are case-insensitive according to https://tools.ietf.org/html/rfc2183
Also this current check will also trigger for Content-Disposition: <something-else>; filename=attachment which is probably not intended.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated accordingly. The question is now the check, I am now checking for attachment; instead.

@@ -98,6 +98,7 @@ public function onKernelResponse(FilterResponseEvent $event)
|| $response->isRedirection()
|| ($response->headers->has('Content-Type') && false === strpos($response->headers->get('Content-Type'), 'html'))
|| 'html' !== $request->getRequestFormat()
|| false !== strpos(strtolower($response->headers->get('Content-Disposition')), 'attachment;')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stripos instead of strpos+strtolower?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

@fabpot
Copy link
Member

fabpot commented Jun 8, 2016

Thank you @peterrehm.

fabpot added a commit that referenced this pull request Jun 8, 2016
This PR was squashed before being merged into the 2.7 branch (closes #18971).

Discussion
----------

Do not inject web debug toolbar on attachments

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #18965
| License       | MIT
| Doc PR        | -

Commits
-------

4a7d836 Do not inject web debug toolbar on attachments
@fabpot fabpot closed this Jun 8, 2016
@peterrehm peterrehm deleted the toolbar branch June 8, 2016 15:18
@fabpot fabpot mentioned this pull request Jun 15, 2016
This was referenced Jun 30, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants