From 3d7d0c40b8e7f1897fc4a323d4edee6db2a7f452 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 6 Mar 2016 11:22:05 +0100 Subject: [ticket/14437] Make sure attachments array is properly ordered before processing PHPBB3-14437 --- phpBB/includes/functions_content.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/includes') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index 725707f7dc..ac3a35f8c9 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -974,6 +974,9 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count, unset($new_attachment_data); } + // Make sure attachments are properly ordered + ksort($attachments); + foreach ($attachments as $attachment) { if (!sizeof($attachment)) @@ -1211,8 +1214,6 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count, $attachments = $compiled_attachments; unset($compiled_attachments); - $tpl_size = sizeof($attachments); - $unset_tpl = array(); preg_match_all('#(.*?)#', $message, $matches, PREG_PATTERN_ORDER); @@ -1220,8 +1221,7 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count, $replace = array(); foreach ($matches[0] as $num => $capture) { - // Flip index if we are displaying the reverse way - $index = $tpl_size-($matches[1][$num] + 1); + $index = $matches[1][$num]; $replace['from'][] = $matches[0][$num]; $replace['to'][] = (isset($attachments[$index])) ? $attachments[$index] : sprintf($user->lang['MISSING_INLINE_ATTACHMENT'], $matches[2][array_search($index, $matches[1])]); -- cgit v1.2.1