Skip to content

Commit

Permalink
Catch exception when invalid country_id is submitted in estimate ship…
Browse files Browse the repository at this point in the history
…ping action. Fixes OpenMage#4417
  • Loading branch information
colinmollenhour committed Dec 20, 2024
1 parent a116622 commit 0db921e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions app/code/core/Mage/Checkout/controllers/CartController.php
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,14 @@ public function estimatePostAction()
$regionId = (string) $this->getRequest()->getParam('region_id');
$region = (string) $this->getRequest()->getParam('region');

try {
Mage::getModel('directory/country')->loadByCode($country);
} catch (Mage_Core_Exception $e) {
$this->_getSession()->addError($e->getMessage());
$this->_goBack();
return;
}

$this->_getQuote()->getShippingAddress()
->setCountryId($country)
->setCity($city)
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Directory/Model/Resource/Region.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ protected function _getLoadSelect($field, $value, $object)
* Load object by country id and code or default name
*
* @param Mage_Core_Model_Abstract $object
* @param int $countryId
* @param string $countryId
* @param string $value
* @param string $field
*
Expand Down

0 comments on commit 0db921e

Please sign in to comment.