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
Fixes #3135, fix opt-out form on Safari browsers by opening new window that sets the cookie. #7754
Conversation
…w that sets the cookie.
@@ -320,21 +320,34 @@ public function trackingCodeGenerator() | |||
*/ | |||
public function optOut() | |||
{ | |||
$reref = Common::getRequestVar('reref', false); | |||
if (!empty($reref)) { | |||
Url::redirectToUrl($reref); |
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.
here is a security vulnerability, "Open redirect": https://www.owasp.org/index.php/Open_redirect
could it be avoided?
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.
actually that's dead code from one of the other attempts at fixing the problem. It can be removed, thanks for catching it!
… exist. If it exists, we don't need to visit in a new window.
… can keep clicking the checkbox.
…m is done submitting.
…iable and added opt-out form screenshot tests.
…window is loaded (also when JS is available, use window.open instead of a form POST).
…n using in submitForm function in optOut.twig.
created new FAQ https://piwik.org/faq/general/faq_20000/ |
Can you smash commits into one and then +1 to merge |
Merged in 7cc3bfc |
As title.
This PR allows us to set 3rd party cookies in the opt-out form for Piwik. It works by opening a new window on form submission, reloading the new window, and setting the cookie on this reload. It is necessary to reload the window, because the session cookie isn't set, so the nonce won't be detected & so, the ignore cookie won't be set.
It works whether JavaScript is enabled or not, and other browsers still get the better UX.
I tried two alternative solutions to provide better UX, but neither worked on the latest version of Safari (Safari 8):
I first tried to do the form POST as an AJAX request and set the cookies manually via JavaScript. This failed when trying to read the cookies sent by the POST; Safari would not allow reading the Set-Cookie response.
I also tried the triple redirect solution described here: http://measurablewins.gregjxn.com/2014/02/safari-setting-third-party-iframe.html?m=1
This failed due to the same origin policy. The iframe cannot access the
top
frame unless they both come from the same domain. It might be possible for the website hosting the iframe to allow this, but Piwik can't control whether the website does this.Tested on Safari in a Mac and on an iPhone.
TODO:
Refs #3135