mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-19 16:11:21 +02:00
[feature/attach-dl] Manually clean the topic title/post subject
PHPBB3-11042
This commit is contained in:
@@ -426,7 +426,6 @@ if ($attachment)
|
|||||||
if ($attachments)
|
if ($attachments)
|
||||||
{
|
{
|
||||||
require_once $phpbb_root_path . 'includes/functions_compress.' . $phpEx;
|
require_once $phpbb_root_path . 'includes/functions_compress.' . $phpEx;
|
||||||
require_once $phpbb_root_path . 'includes/functions_upload.' . $phpEx;
|
|
||||||
phpbb_increment_downloads($db, $attachment_ids);
|
phpbb_increment_downloads($db, $attachment_ids);
|
||||||
|
|
||||||
if (!in_array($archive, compress::methods()))
|
if (!in_array($archive, compress::methods()))
|
||||||
@@ -451,20 +450,11 @@ if ($attachments)
|
|||||||
$row = $db->sql_fetchrow($result);
|
$row = $db->sql_fetchrow($result);
|
||||||
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
$filespec = new filespec(array(
|
$bad_chars = array("'", "\\", ' ', '/', ':', '*', '?', '"', '<', '>', '|');
|
||||||
'tmp_name' => '',
|
$clean_name = ($post_id) ? $row['post_subject'] : $row['topic_title'];
|
||||||
'size' => 0,
|
$clean_name = rawurlencode(str_replace($bad_chars, '_', strtolower($clean_name)));
|
||||||
'name' => ($post_id) ? $row['post_subject'] : $row['topic_title'],
|
$clean_name = preg_replace("/%(\w{2})/", '_', $clean_name);
|
||||||
'type' => '',
|
$suffix = '_' . (($post_id) ? $post_id : $topic_id) . '_' . $clean_name;
|
||||||
));
|
|
||||||
$filespec->clean_filename('real');
|
|
||||||
$suffix = '_' . (($post_id) ? $post_id : $topic_id) . '_' . $filespec->realname;
|
|
||||||
|
|
||||||
// Remove trailing full stop
|
|
||||||
if (strrpos($suffix, '.') === strlen($suffix) - 1)
|
|
||||||
{
|
|
||||||
$suffix = substr($suffix, 0, strlen($suffix) - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
$store_name = 'att_' . time() . '_' . unique_id();
|
$store_name = 'att_' . time() . '_' . unique_id();
|
||||||
$archive_name = 'attachments' . $suffix;
|
$archive_name = 'attachments' . $suffix;
|
||||||
|
Reference in New Issue
Block a user