Skip to content

Commit

Permalink
Merge pull request #9 from manish172/magento-1.9
Browse files Browse the repository at this point in the history
Applied Security patch from Magento: PATCH_SUPEE-5344_CE
  • Loading branch information
LeeSaferite committed Feb 10, 2015
2 parents 1e195ab + 5924277 commit 4e071c3
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 10 deletions.
11 changes: 8 additions & 3 deletions app/code/core/Mage/Admin/Model/Observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ public function actionPreDispatchAdmin($observer)
{
$session = Mage::getSingleton('admin/session');
/** @var $session Mage_Admin_Model_Session */

/**
* @var $request Mage_Core_Controller_Request_Http
*/
$request = Mage::app()->getRequest();
$user = $session->getUser();

Expand All @@ -58,7 +62,7 @@ public function actionPreDispatchAdmin($observer)
if (in_array($requestedActionName, $openActions)) {
$request->setDispatched(true);
} else {
if($user) {
if ($user) {
$user->reload();
}
if (!$user || !$user->getId()) {
Expand All @@ -69,13 +73,14 @@ public function actionPreDispatchAdmin($observer)
$session->login($username, $password, $request);
$request->setPost('login', null);
}
if (!$request->getParam('forwarded')) {
if (!$request->getInternallyForwarded()) {
$request->setInternallyForwarded();
if ($request->getParam('isIframe')) {
$request->setParam('forwarded', true)
->setControllerName('index')
->setActionName('deniedIframe')
->setDispatched(false);
} elseif($request->getParam('isAjax')) {
} elseif ($request->getParam('isAjax')) {
$request->setParam('forwarded', true)
->setControllerName('index')
->setActionName('deniedJson')
Expand Down
29 changes: 29 additions & 0 deletions app/code/core/Mage/Core/Controller/Request/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ class Mage_Core_Controller_Request_Http extends Zend_Controller_Request_Http
*/
protected $_beforeForwardInfo = array();

/**
* Flag for recognizing if request internally forwarded
*
* @var bool
*/
protected $_internallyForwarded = false;

/**
* Returns ORIGINAL_PATH_INFO.
* This value is calculated instead of reading PATH_INFO
Expand Down Expand Up @@ -534,4 +541,26 @@ public function isAjax()
}
return false;
}

/**
* Define that request was forwarded internally
*
* @param boolean $flag
* @return Mage_Core_Controller_Request_Http
*/
public function setInternallyForwarded($flag = true)
{
$this->_internallyForwarded = (bool)$flag;
return $this;
}

/**
* Checks if request was forwarded internally
*
* @return bool
*/
public function getInternallyForwarded()
{
return $this->_internallyForwarded;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class Mage_Oauth_Adminhtml_Oauth_AuthorizeController extends Mage_Adminhtml_Cont
*/
public function preDispatch()
{
$this->getRequest()->setParam('forwarded', true);
Mage::app()->getRequest()->setInternallyForwarded();

// check login data before it set null in Mage_Admin_Model_Observer::actionPreDispatchAdmin
$loginError = $this->_checkLoginIsEmpty();
Expand Down
4 changes: 2 additions & 2 deletions app/code/core/Mage/XmlConnect/Model/Observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public function actionFrontPreDispatchXmlAdmin($event)
/** @var $request Mage_Core_Controller_Request_Http */
$request = Mage::app()->getRequest();
if (true === $this->_checkAdminController($request, $event->getControllerAction())) {
$request->setParam('forwarded', true)->setDispatched(true);
$request->setInternallyForwarded()->setDispatched(true);
}
}

Expand All @@ -160,7 +160,7 @@ public function actionPreDispatchXmlAdmin($event)
if (false === $this->_checkAdminController($request, $event->getControllerAction())
&& !Mage::getSingleton('admin/session')->isLoggedIn()
) {
$request->setParam('forwarded', true)->setRouteName('adminhtml')->setControllerName('connect_user')
$request->setInternallyForwarded()->setRouteName('adminhtml')->setControllerName('connect_user')
->setActionName('loginform')->setDispatched(false);
}
}
Expand Down
4 changes: 0 additions & 4 deletions lib/Varien/Db/Adapter/Pdo/Mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -2834,10 +2834,6 @@ public function prepareSqlCondition($fieldName, $condition)

$query = '';
if (is_array($condition)) {
if (isset($condition['field_expr'])) {
$fieldName = str_replace('#?', $this->quoteIdentifier($fieldName), $condition['field_expr']);
unset($condition['field_expr']);
}
$key = key(array_intersect_key($condition, $conditionKeyMap));

if (isset($condition['from']) || isset($condition['to'])) {
Expand Down

0 comments on commit 4e071c3

Please sign in to comment.