Skip to content
This repository has been archived by the owner on Mar 27, 2019. It is now read-only.

Magento 1.8.1.0 patch 4 #64

Open
wants to merge 5 commits into
base: magento-1.8.1.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/code/core/Mage/Admin/Model/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ public function login($username, $password, $request = null)
Mage::throwException(Mage::helper('adminhtml')->__('Invalid User Name or Password.'));
}
} catch (Mage_Core_Exception $e) {
$e->setMessage(
Mage::helper('adminhtml')->__('You did not sign in correctly or your account is temporarily disabled.')
);
Mage::dispatchEvent('admin_session_user_login_failed',
array('user_name' => $username, 'exception' => $e));
if ($request && !$request->getParam('messageSent')) {
Expand Down
52 changes: 52 additions & 0 deletions app/code/core/Mage/Adminhtml/Block/Checkout/Formkey.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category Mage
* @package Mage_Adminhtml
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

/**
* Class Mage_Adminhtml_Block_Checkout_Formkey
*/
class Mage_Adminhtml_Block_Checkout_Formkey extends Mage_Adminhtml_Block_Template
{
/**
* Check form key validation on checkout.
* If disabled, show notice.
*
* @return boolean
*/
public function canShow()
{
return !Mage::getStoreConfigFlag('admin/security/validate_formkey_checkout');
}

/**
* Get url for edit Advanced -> Admin section
*
* @return string
*/
public function getSecurityAdminUrl()
{
return Mage::helper("adminhtml")->getUrl('adminhtml/system_config/edit/section/admin');
}
}
36 changes: 36 additions & 0 deletions app/code/core/Mage/Adminhtml/Block/Notification/Symlink.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category Mage
* @package Mage_Adminhtml
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

class Mage_Adminhtml_Block_Notification_Symlink extends Mage_Adminhtml_Block_Template
{
/**
* @return bool
*/
public function isSymlinkEnabled()
{
return Mage::getStoreConfigFlag(self::XML_PATH_TEMPLATE_ALLOW_SYMLINK);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,11 @@ public function setValue($value)
if (isset($value['locale'])) {
if (!empty($value['from'])) {
$value['orig_from'] = $value['from'];
$value['from'] = $this->_convertDate($value['from'], $value['locale']);
$value['from'] = $this->_convertDate($this->stripTags($value['from']), $value['locale']);
}
if (!empty($value['to'])) {
$value['orig_to'] = $value['to'];
$value['to'] = $this->_convertDate($value['to'], $value['locale']);
$value['to'] = $this->_convertDate($this->stripTags($value['to']), $value['locale']);
}
}
if (empty($value['from']) && empty($value['to'])) {
Expand Down
3 changes: 3 additions & 0 deletions app/code/core/Mage/Adminhtml/Model/Config/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ public function save()
if (is_object($fieldConfig)) {
$configPath = (string)$fieldConfig->config_path;
if (!empty($configPath) && strrpos($configPath, '/') > 0) {
if (!Mage::getSingleton('admin/session')->isAllowed($configPath)) {
Mage::throwException('Access denied.');
}
// Extend old data with specified section group
$groupPath = substr($configPath, 0, strrpos($configPath, '/'));
if (!isset($oldConfigAdditionalGroups[$groupPath])) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category Mage
* @package Mage_Adminhtml
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
class Mage_Adminhtml_Model_System_Config_Backend_Web_Secure_Offloaderheader extends Mage_Core_Model_Config_Data
{
protected $_eventPrefix = 'core_config_backend_web_secure_offloaderheader';
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ public function uploadAction()
Mage::helper('catalog/image'), 'validateUploadFile');
$uploader->setAllowRenameFiles(true);
$uploader->setFilesDispersion(true);
$uploader->addValidateCallback(
Mage_Core_Model_File_Validator_Image::NAME,
Mage::getModel('core/file_validator_image'),
'validate'
);
$result = $uploader->save(
Mage::getSingleton('catalog/product_media_config')->getBaseTmpMediaPath()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,12 @@ public function addressesPostAction()
$this->_redirect('*/multishipping_address/newShipping');
return;
}

if ($this->isFormkeyValidationOnCheckoutEnabled() && !$this->_validateFormKey()) {
$this->_redirect('*/*/addresses');
return;
}

try {
if ($this->getRequest()->getParam('continue', false)) {
$this->_getCheckout()->setCollectRatesFlag(true);
Expand Down Expand Up @@ -353,6 +359,11 @@ public function backToShippingAction()
*/
public function shippingPostAction()
{
if ($this->isFormkeyValidationOnCheckoutEnabled() && !$this->_validateFormKey()) {
$this->_redirect('*/*/shipping');
return;
}

$shippingMethods = $this->getRequest()->getPost('shipping_method');
try {
Mage::dispatchEvent(
Expand Down Expand Up @@ -439,6 +450,11 @@ public function overviewAction()
return $this;
}

if ($this->isFormkeyValidationOnCheckoutEnabled() && !$this->_validateFormKey()) {
$this->_redirect('*/*/billing');
return;
}

$this->_getState()->setActiveStep(Mage_Checkout_Model_Type_Multishipping_State::STEP_OVERVIEW);

try {
Expand Down
25 changes: 25 additions & 0 deletions app/code/core/Mage/Checkout/controllers/OnepageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,11 @@ public function saveMethodAction()
if ($this->_expireAjax()) {
return;
}

if ($this->isFormkeyValidationOnCheckoutEnabled() && !$this->_validateFormKey()) {
return;
}

if ($this->getRequest()->isPost()) {
$method = $this->getRequest()->getPost('method');
$result = $this->getOnepage()->saveCheckoutMethod($method);
Expand All @@ -365,6 +370,11 @@ public function saveBillingAction()
if ($this->_expireAjax()) {
return;
}

if ($this->isFormkeyValidationOnCheckoutEnabled() && !$this->_validateFormKey()) {
return;
}

if ($this->getRequest()->isPost()) {
$data = $this->getRequest()->getPost('billing', array());
$customerAddressId = $this->getRequest()->getPost('billing_address_id', false);
Expand Down Expand Up @@ -407,6 +417,11 @@ public function saveShippingAction()
if ($this->_expireAjax()) {
return;
}

if ($this->isFormkeyValidationOnCheckoutEnabled() && !$this->_validateFormKey()) {
return;
}

if ($this->getRequest()->isPost()) {
$data = $this->getRequest()->getPost('shipping', array());
$customerAddressId = $this->getRequest()->getPost('shipping_address_id', false);
Expand All @@ -431,6 +446,11 @@ public function saveShippingMethodAction()
if ($this->_expireAjax()) {
return;
}

if ($this->isFormkeyValidationOnCheckoutEnabled() && !$this->_validateFormKey()) {
return;
}

if ($this->getRequest()->isPost()) {
$data = $this->getRequest()->getPost('shipping_method', '');
$result = $this->getOnepage()->saveShippingMethod($data);
Expand Down Expand Up @@ -465,6 +485,11 @@ public function savePaymentAction()
if ($this->_expireAjax()) {
return;
}

if ($this->isFormkeyValidationOnCheckoutEnabled() && !$this->_validateFormKey()) {
return;
}

try {
if (!$this->getRequest()->isPost()) {
$this->_ajaxRedirectResponse();
Expand Down
18 changes: 18 additions & 0 deletions app/code/core/Mage/Checkout/etc/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -232,5 +232,23 @@
</payment_failed>
</groups>
</checkout>
<admin>
<groups>
<security>
<fields>
<validate_formkey_checkout translate="label comment">
<label>Enable Form Key Validation On Checkout</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_yesno</source_model>
<sort_order>4</sort_order>
<comment><![CDATA[<strong style="color:red">Important!</strong> Enabling this option means
that your custom templates used in checkout process contain form_key output.
Otherwise checkout may not work.]]></comment>
<show_in_default>1</show_in_default>
</validate_formkey_checkout>
</fields>
</security>
</groups>
</admin>
</sections>
</config>
5 changes: 5 additions & 0 deletions app/code/core/Mage/Cms/Model/Wysiwyg/Images/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,11 @@ public function uploadFile($targetPath, $type = null)
}
$uploader->setAllowRenameFiles(true);
$uploader->setFilesDispersion(false);
$uploader->addValidateCallback(
Mage_Core_Model_File_Validator_Image::NAME,
Mage::getModel('core/file_validator_image'),
'validate'
);
$result = $uploader->save($targetPath);

if (!$result) {
Expand Down
39 changes: 39 additions & 0 deletions app/code/core/Mage/Core/Controller/Front/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ class Mage_Core_Controller_Front_Action extends Mage_Core_Controller_Varien_Acti
*/
const SESSION_NAMESPACE = 'frontend';

/**
* Add secret key to url config path
*/
const XML_CSRF_USE_FLAG_CONFIG_PATH = 'system/csrf/use_form_key';

/**
* Currently used area
*
Expand Down Expand Up @@ -159,4 +164,38 @@ protected function _prepareDownloadResponse($fileName, $content, $contentType =
}
return $this;
}

/**
* Validate Form Key
*
* @return bool
*/
protected function _validateFormKey()
{
$validated = true;
if ($this->_isFormKeyEnabled()) {
$validated = parent::_validateFormKey();
}
return $validated;
}

/**
* Check if form key validation is enabled.
*
* @return bool
*/
protected function _isFormKeyEnabled()
{
return Mage::getStoreConfigFlag(self::XML_CSRF_USE_FLAG_CONFIG_PATH);
}

/**
* Check if form_key validation enabled on checkout process
*
* @return bool
*/
protected function isFormkeyValidationOnCheckoutEnabled()
{
return Mage::getStoreConfigFlag('admin/security/validate_formkey_checkout');
}
}
5 changes: 4 additions & 1 deletion app/code/core/Mage/Core/Controller/Request/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,10 @@ public function setPathInfo($pathInfo = null)
$baseUrl = $this->getBaseUrl();
$pathInfo = substr($requestUri, strlen($baseUrl));

if ((null !== $baseUrl) && (false === $pathInfo)) {
if ($baseUrl && $pathInfo && (0 !== stripos($pathInfo, '/'))) {
$pathInfo = '';
$this->setActionName('noRoute');
} elseif ((null !== $baseUrl) && (false === $pathInfo)) {
$pathInfo = '';
} elseif (null === $baseUrl) {
$pathInfo = $requestUri;
Expand Down
Loading