-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Limit storePreviousURL to certain requests #2126
Conversation
system/CodeIgniter.php
Outdated
@@ -968,6 +969,12 @@ protected function gatherOutput($cacheConfig = null, $returned = null) | |||
*/ | |||
public function storePreviousURL($uri) | |||
{ | |||
// Only valid for some requests | |||
if (! $this->request instanceof IncomingRequest || $this->request->isCLI() || $this->request->isAJAX()) |
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.
I'm a little concerned with checking against IncomingRequest. it's entirely possible for someone to use a completely different IncomingRequest-like class. While I would think they would extend IncomingRequest there's nothing that limits them from doing something crazy. Better to either not check against a class type and just do the AJAX and CLI checks, or check against Request.
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.
That is how I had it originally but since neither Request nor RequestInterface require isAJAX()
and isCLI()
it was causing issues, e.g. CLI requests where giving "method doesn't exist" exceptions.
I guess I will try it by checking for each method, but I'm also open to an additional interface or some other means of defining a "browser visit".
system/CodeIgniter.php
Outdated
// Only valid for some requests | ||
if (! $this->request instanceof IncomingRequest || $this->request->isCLI() || $this->request->isAJAX()) | ||
// Ignore CLI requests | ||
if (method_exists($this->request, 'isCLI') && $this->request->isCLI()) |
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.
is_cli()
is an available function provided in Common.php, so no need to check, just use the helper function.
Unfortunately, none exists for is_ajax.
You had a productive night! I’ll make that change. Would you like me to take a crack at |
Feel free to take a look at it. I think that it requires info from IncomingRequest, though. |
Okay I'll look at that later - we'll pick the low-hanging fruit for now. |
@lonnieezell This one is all set. |
is_ajax would be a IncomingRequest because it gets a lot of the information from $_SERVER[] |
Description
Currently
storePreviousUrl()
will fire on AJAX requests, saving the URL from the AJAX request and causingredirect()->back()
to return to routes that probably were never intended for direct browsing.This change causes
$_SESSION
to be updated only when it is a validIncomingRequest
that is notCLI
orAJAX
(including these additional parameters helps with testing).Checklist: