Skip to content

Commit

Permalink
bugfix/adminhtmlSystemConfigBackendFile: fix _getUploadRoot and _getA…
Browse files Browse the repository at this point in the history
…llowedExtensions ( OpenMage#3933 )
  • Loading branch information
eneiasramos committed May 24, 2024
1 parent 2dc3046 commit 7247c12
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions app/code/core/Mage/Adminhtml/Model/System/Config/Backend/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
*/
class Mage_Adminhtml_Model_System_Config_Backend_File extends Mage_Core_Model_Config_Data
{
public const SYSTEM_FILESYSTEM_REGEX = '/{{([a-z_]+)}}(.*)/';

/**
* Upload max file size in kilobytes
*
Expand Down Expand Up @@ -144,6 +146,12 @@ protected function _getUploadDir()
*/
protected function _getUploadRoot($token)
{
$value = Mage::getStoreConfig($token);
if (preg_match(self::SYSTEM_FILESYSTEM_REGEX, $value, $matches) !== false) {
$dir = str_replace('root_dir', 'base_dir', $matches[1]);
$path = str_replace('/', DS, $matches[2]);
return Mage::getConfig()->getOptions()->getData($dir) . $path;
}
return Mage::getBaseDir('media');
}

Expand Down Expand Up @@ -188,6 +196,13 @@ protected function _appendScopeInfo($path)
*/
protected function _getAllowedExtensions()
{
/** @var Varien_Simplexml_Element $fieldConfig */
$fieldConfig = $this->getFieldConfig();
$el = $fieldConfig->descend('upload_dir');
if (!empty($el['allowed_extensions'])) {
$allowedExtensions = (string)$el['allowed_extensions'];
return explode(',', $allowedExtensions);
}
return [];
}

Expand Down

0 comments on commit 7247c12

Please sign in to comment.