1

Am using $this->_redirectReferer(); to redirect back to category page.
when i use some params, my url is like
electronics.html?color=24&manufacturer=117&price=-1000
then the redirected url is like
electronics.html?color=24&am;manufacturer=117&am;price=-1000
my url is encoded. all the & is changed to {&amp};
how can i avoid this.

0

The method Mage_Core_Controller_Varien_Action::_redirectReferer calls _getRefererUrl from the same class that contains this line:

$refererUrl = Mage::helper('core')->escapeUrl($refererUrl);

The escape url is basically htmlspecialchars().

You shouldn't change the _getRefererUrl method because it's risky, but you can write your own method similar with the _redirectReferer where you undo the htmlspecial chars and use that method:

Something like this:

protected function _redirectRefererNoSpecialChars($defaultUrl=null)
{

    $refererUrl = $this->_getRefererUrl();
    $refererUrl = htmlspecialchars_decode($str, ENT_NOQUOTES);//this needs to be added
    if (empty($refererUrl)) {
        $refererUrl = empty($defaultUrl) ? Mage::getBaseUrl() : $defaultUrl;
    }

    $this->getResponse()->setRedirect($refererUrl);
    return $this;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.