User tests: Successful: Unsuccessful:
The fields in Email this link to a friend
form can be renamed resulting in undefined index notices upon submission. This PR checks that these fields exist before performing operations to them.
Email
in the dropdownsender
and subject
to sender2
and subject2
no notices
In PHP error log:
PHP Notice: Undefined index: sender in \components\com_mailto\controller.php on line 97
PHP Notice: Undefined index: subject in \components\com_mailto\controller.php on line 97
no
Status | New | ⇒ | Pending |
Category | ⇒ | Front End com_mailto |
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2018-05-02 01:58:07 |
Closed_By | ⇒ | Quy |
Labels |
Added:
?
|
This PR is included in PR #20265.
if (!empty($_POST[$field]))
This check is no longer required when using $data
and getData()
in your PR. Please consider my suggestion in your PR.
Why should it no longer required?
Here is my proposed change:
remove:
// An array of the input fields to scan for injected headers
$fields = array(
'emailto',
'sender',
'emailfrom',
'subject',
'link',
'captcha',
);
change to:
foreach ($data as $key => $value)
{
foreach ($headers as $header)
{
if (strpos($value, $header) !== false)
{
JError::raiseError(403, '');
}
}
}
In other words, you got the data here so no need to do this check if (!empty($_POST[$field]))
.
public function getData()
{
$input = JFactory::getApplication()->input;
$data['emailto'] = $input->get('emailto', '', 'string');
$data['sender'] = $input->get('sender', '', 'string');
$data['emailfrom'] = $input->get('emailfrom', '', 'string');
$data['subject'] = $input->get('subject', '', 'string');
$data['captcha'] = $input->get('captcha', '', 'string');
return $data;
}
Pushed thanks
I have tested this item✅ successfully on ee761cb
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/20092.