mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 22:28:51 +00:00
[feature/attach-dl] phpbb_check_attach_extensions: Get rid of pass-by-reference
PHPBB3-11042
This commit is contained in:
parent
b6d4ee4244
commit
bba348d68a
2 changed files with 10 additions and 18 deletions
|
@ -285,16 +285,9 @@ else if ($download_id)
|
||||||
|
|
||||||
// disallowed?
|
// disallowed?
|
||||||
$extensions = $cache->obtain_attach_extensions($row['forum_id']);
|
$extensions = $cache->obtain_attach_extensions($row['forum_id']);
|
||||||
if ($attachment)
|
|
||||||
{
|
|
||||||
$ary = array($attachment);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$ary = &$attachments;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!phpbb_check_attach_extensions($extensions, $ary))
|
$attachments_filtered = phpbb_filter_disallowed_extensions($extensions, array($attachment));
|
||||||
|
if (empty($attachments_filtered))
|
||||||
{
|
{
|
||||||
send_status_line(404, 'Forbidden');
|
send_status_line(404, 'Forbidden');
|
||||||
trigger_error(sprintf($user->lang['EXTENSION_DISABLED_AFTER_POSTING'], $attachment['extension']));
|
trigger_error(sprintf($user->lang['EXTENSION_DISABLED_AFTER_POSTING'], $attachment['extension']));
|
||||||
|
|
|
@ -618,21 +618,20 @@ function phpbb_increment_downloads($db, $ids)
|
||||||
* Checks every attachment to see if it has an allowed extension
|
* Checks every attachment to see if it has an allowed extension
|
||||||
*
|
*
|
||||||
* @param array $extensions As generated by phpbb_cache_service::obtain_attach_extensions
|
* @param array $extensions As generated by phpbb_cache_service::obtain_attach_extensions
|
||||||
* @param array &$attachments An array of attachments to check
|
* @param array $attachments An array of attachment row to check
|
||||||
*
|
*
|
||||||
* @return bool Whether any of the attachments had allowed extensions
|
* @return array Array of attachment rows with allowed extension
|
||||||
*/
|
*/
|
||||||
function phpbb_check_attach_extensions($extensions, &$attachments)
|
function phpbb_filter_disallowed_extensions($extensions, $attachments)
|
||||||
{
|
{
|
||||||
$new_ary = array();
|
$result = array();
|
||||||
foreach ($attachments as $attach)
|
foreach ($attachments as $row)
|
||||||
{
|
{
|
||||||
if (isset($extensions['_allowed_'][$attach['extension']]))
|
if (isset($extensions['_allowed_'][$row['extension']]))
|
||||||
{
|
{
|
||||||
$new_ary[] = $attach;
|
$result[] = $row;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$attachments = $new_ary;
|
return $result;
|
||||||
return !empty($attachments);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue