Skip to content

Commit

Permalink
Merge pull request from GHSA-4gpr-p634-922x
Browse files Browse the repository at this point in the history
  • Loading branch information
ausi committed Jul 25, 2023
1 parent 0f0bea8 commit 5c9aff3
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 35 deletions.
22 changes: 11 additions & 11 deletions core-bundle/src/Resources/contao/widgets/InputUnit.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@ class InputUnit extends Widget
*/
protected $strTemplate = 'be_widget';

/**
* Units
* @var array
*/
protected $arrUnits = array();

/**
* Add specific attributes
*
Expand Down Expand Up @@ -74,7 +68,7 @@ public function __set($strKey, $varValue)
break;

case 'options':
$this->arrUnits = StringUtil::deserialize($varValue);
$this->arrOptions = StringUtil::deserialize($varValue);
break;

default:
Expand All @@ -84,8 +78,6 @@ public function __set($strKey, $varValue)
}

/**
* Do not validate unit fields
*
* @param mixed $varInput
*
* @return mixed
Expand All @@ -94,7 +86,15 @@ protected function validator($varInput)
{
foreach ($varInput as $k=>$v)
{
if ($k != 'unit')
if ($k == 'unit')
{
if (!$this->isValidOption($v))
{
$varInput[$k] = '';
$this->addError($GLOBALS['TL_LANG']['ERR']['invalid']);
}
}
else
{
$varInput[$k] = parent::validator($v);
}
Expand Down Expand Up @@ -134,7 +134,7 @@ public function generate()
{
$arrUnits = array();

foreach ($this->arrUnits as $arrUnit)
foreach ($this->arrOptions as $arrUnit)
{
$arrUnits[] = sprintf(
'<option value="%s"%s>%s</option>',
Expand Down
26 changes: 13 additions & 13 deletions core-bundle/src/Resources/contao/widgets/TimePeriod.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@ class TimePeriod extends Widget
*/
protected $strTemplate = 'be_widget';

/**
* Units
* @var array
*/
protected $arrUnits = array();

/**
* Add specific attributes
*
Expand Down Expand Up @@ -69,7 +63,7 @@ public function __set($strKey, $varValue)
break;

case 'options':
$this->arrUnits = StringUtil::deserialize($varValue);
$this->arrOptions = StringUtil::deserialize($varValue);
break;

default:
Expand All @@ -79,8 +73,6 @@ public function __set($strKey, $varValue)
}

/**
* Do not validate unit fields
*
* @param mixed $varInput
*
* @return mixed
Expand All @@ -89,7 +81,15 @@ protected function validator($varInput)
{
foreach ($varInput as $k=>$v)
{
if ($k != 'unit')
if ($k == 'unit')
{
if (!$this->isValidOption($v))
{
$varInput[$k] = '';
$this->addError($GLOBALS['TL_LANG']['ERR']['invalid']);
}
}
else
{
$varInput[$k] = parent::validator($v);
}
Expand Down Expand Up @@ -130,12 +130,12 @@ public function generate()
$arrUnits = array();

// Add an empty option if there are none (see #5067)
if (empty($this->arrUnits))
if (empty($this->arrOptions))
{
$this->arrUnits = array(array('value'=>'', 'label'=>'-'));
$this->arrOptions = array(array('value'=>'', 'label'=>'-'));
}

foreach ($this->arrUnits as $arrUnit)
foreach ($this->arrOptions as $arrUnit)
{
$arrUnits[] = sprintf(
'<option value="%s"%s>%s</option>',
Expand Down
22 changes: 11 additions & 11 deletions core-bundle/src/Resources/contao/widgets/TrblField.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ class TrblField extends Widget
*/
protected $strTemplate = 'be_widget';

/**
* Units
* @var array
*/
protected $arrUnits = array();

/**
* Add specific attributes
*
Expand All @@ -56,7 +50,7 @@ public function __set($strKey, $varValue)
break;

case 'options':
$this->arrUnits = StringUtil::deserialize($varValue);
$this->arrOptions = StringUtil::deserialize($varValue);
break;

default:
Expand All @@ -66,8 +60,6 @@ public function __set($strKey, $varValue)
}

/**
* Do not validate unit fields
*
* @param mixed $varInput
*
* @return mixed
Expand All @@ -76,7 +68,15 @@ protected function validator($varInput)
{
foreach ($varInput as $k=>$v)
{
if ($k != 'unit')
if ($k == 'unit')
{
if (!$this->isValidOption($v))
{
$varInput[$k] = '';
$this->addError($GLOBALS['TL_LANG']['ERR']['invalid']);
}
}
else
{
$varInput[$k] = parent::validator($v);
}
Expand Down Expand Up @@ -116,7 +116,7 @@ public function generate()
{
$arrUnits = array();

foreach ($this->arrUnits as $arrUnit)
foreach ($this->arrOptions as $arrUnit)
{
$arrUnits[] = sprintf(
'<option value="%s"%s>%s</option>',
Expand Down

0 comments on commit 5c9aff3

Please sign in to comment.