Skip to content

array_merge_recursive rather than delay setting the flash messages cookie #559

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

Merged
merged 2 commits into from
Jan 26, 2021

Conversation

dbu
Copy link
Contributor

@dbu dbu commented Jan 26, 2021

fix #558

@dbu dbu force-pushed the fix-flash-cookie-handling branch 2 times, most recently from 5c76d46 to 082aa4a Compare January 26, 2021 09:18
we recently fixed that we lose previous cookies. but the fix was keeping
the messages in the session and only setting the cookie on the last
redirect, which means the messages are lost if the session is destroyed
(e.g. redirect to page outside firewall)

changed to merge the flash messages cookie from requests into the
flashes. and using array_merge_recursive to keep multiple messages with
the same key.
@dbu dbu force-pushed the fix-flash-cookie-handling branch from 082aa4a to afe9c56 Compare January 26, 2021 09:21
@dbu dbu force-pushed the fix-flash-cookie-handling branch from afe9c56 to 4970863 Compare January 26, 2021 09:23
@dbu
Copy link
Contributor Author

dbu commented Jan 26, 2021

@ismailcherri @spointecker may I ask you two to review this pull request and tell if you see any new pitfalls i might be introducing here?

// Preserve existing flash message cookie from previous redirect if there was one.
// This covers multiple redirects where each redirect adds flash messages.
$request = $event->getRequest();
if ($request->cookies->has($this->options['name'])) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

before, we did not look at request cookies at all.

i was wondering if there is a security risk involved with this (depending on what weird things a dev might put into a flash message) but i guess if the attacker manages to inject a cookie for this domain, they can also do more direct attacks with javascript that do not involve looping through the backend.

@spointecker
Copy link

LGTM. Thanks for the quick answer and fix, will test it with my app&tests as soon as it is released!

@ismailcherri
Copy link

LGTM. Thanks for the fix.

@dbu dbu merged commit 7b15962 into 2.9.x Jan 26, 2021
@dbu dbu deleted the fix-flash-cookie-handling branch January 26, 2021 12:39
@dbu
Copy link
Contributor Author

dbu commented Jan 26, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants