ZF-7380: gotoReferer for Zend_Controller_Action_Helper_Redirector

Description

It would be fine to have a function wich redirects you to the referer, like:

/** * Redirects to the refering page if one exists; * If not does nothing; * * $options is an optional associative array that can be used to control * redirect behaviour. The available option keys are: * - exit: boolean flag indicating whether or not to halt script execution when done * - prependBase: boolean flag indicating whether or not to prepend the base URL when a relative URL is provided * - code: integer HTTP status code to use with redirect. Should be between 300 and 307. * * @param array $options * @return void */ public function gotoReferer(array $options = array()) { if($this->getRequest() instanceof Zend_Controller_Request_Http) { $referer = $this->getRequest()->getHeader('REFERER'); $this->gotoUrl($referer, $options); } }

Comments

Please, note that referer might be not present in some cases. Advanced http clients can easilly play with it (spoof it), or simply suppress it

Yes that's true for sure, but like in most cases if you are aware of security concerns it can be usefull.

Hmm, maybee if no referer is present it should be false returned or simply null. Don't know witch fits more for ZF.

I think it would be better to add a getReferer() method to Zend_Controller_Request_Http which would return null if the referer url could not be determined. Then you could just feed the url returned by that getReferer() method to the redirector action helper.

Btw, if the referer is always (on lighttpd, apache and IIS) in $_SERVER['HTTP_REFERER'] I think we don't need any of this at all.

Bulk change of all issues last updated before 1st January 2010 as "Won't Fix".

Feel free to re-open and provide a patch if you want to fix this issue.