[ticket/14285] Remove support for old internet explorer versions

PHPBB3-14285
This commit is contained in:
Rubén Calvo 2018-06-29 18:38:26 +02:00 committed by rubencm
parent dd06933324
commit 8dcf8a4ddb
2 changed files with 20 additions and 30 deletions

View file

@ -23,6 +23,8 @@ if (!defined('IN_PHPBB'))
* Wraps an url into a simple html page. Used to display attachments in IE. * Wraps an url into a simple html page. Used to display attachments in IE.
* this is a workaround for now; might be moved to template system later * this is a workaround for now; might be moved to template system later
* direct any complaints to 1 Microsoft Way, Redmond * direct any complaints to 1 Microsoft Way, Redmond
*
* @deprecated: 3.3.0-dev (To be removed: 4.0.0)
*/ */
function wrap_img_in_html($src, $title) function wrap_img_in_html($src, $title)
{ {
@ -124,10 +126,7 @@ function send_file_to_browser($attachment, $category)
// Send out the Headers. Do not set Content-Disposition to inline please, it is a security measure for users using the Internet Explorer. // Send out the Headers. Do not set Content-Disposition to inline please, it is a security measure for users using the Internet Explorer.
header('Content-Type: ' . $attachment['mimetype']); header('Content-Type: ' . $attachment['mimetype']);
if (phpbb_is_greater_ie_version($user->browser, 7)) header('X-Content-Type-Options: nosniff');
{
header('X-Content-Type-Options: nosniff');
}
if (empty($user->browser) || ((strpos(strtolower($user->browser), 'msie') !== false) && !phpbb_is_greater_ie_version($user->browser, 7))) if (empty($user->browser) || ((strpos(strtolower($user->browser), 'msie') !== false) && !phpbb_is_greater_ie_version($user->browser, 7)))
{ {
@ -316,20 +315,17 @@ function set_modified_headers($stamp, $browser)
// let's see if we have to send the file at all // let's see if we have to send the file at all
$last_load = $request->header('If-Modified-Since') ? strtotime(trim($request->header('If-Modified-Since'))) : false; $last_load = $request->header('If-Modified-Since') ? strtotime(trim($request->header('If-Modified-Since'))) : false;
if (strpos(strtolower($browser), 'msie 6.0') === false && !phpbb_is_greater_ie_version($browser, 7)) if ($last_load !== false && $last_load >= $stamp)
{ {
if ($last_load !== false && $last_load >= $stamp) send_status_line(304, 'Not Modified');
{ // seems that we need those too ... browsers
send_status_line(304, 'Not Modified'); header('Cache-Control: private');
// seems that we need those too ... browsers header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 31536000) . ' GMT');
header('Cache-Control: private'); return true;
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 31536000) . ' GMT'); }
return true; else
} {
else header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $stamp) . ' GMT');
{
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $stamp) . ' GMT');
}
} }
return false; return false;
} }
@ -646,6 +642,8 @@ function phpbb_download_check_pm_auth($db, $user_id, $msg_id)
* @param int $version IE version to check against * @param int $version IE version to check against
* *
* @return bool true if internet explorer version is greater than $version * @return bool true if internet explorer version is greater than $version
*
* @deprecated: 3.3.0-dev (To be removed: 4.0.0)
*/ */
function phpbb_is_greater_ie_version($user_agent, $version) function phpbb_is_greater_ie_version($user_agent, $version)
{ {

View file

@ -214,24 +214,16 @@ class attachment extends controller
); );
extract($this->phpbb_dispatcher->trigger_event('core.download_file_send_to_browser_before', compact($vars))); extract($this->phpbb_dispatcher->trigger_event('core.download_file_send_to_browser_before', compact($vars)));
if ($display_cat == ATTACHMENT_CATEGORY_IMAGE && $mode === 'view' && (strpos($attachment['mimetype'], 'image') === 0) && (strpos(strtolower($user->browser), 'msie') !== false) && !phpbb_is_greater_ie_version($user->browser, 7)) if (!empty($redirect))
{ {
wrap_img_in_html(append_sid($phpbb_root_path . 'download/file.' . $phpEx, 'id=' . $attachment['attach_id']), $attachment['real_filename']); redirect($redirect, false, true);
file_gc();
} }
else else
{ {
if (!empty($redirect)) send_file_to_browser($attachment, $display_cat);
{
redirect($redirect, false, true);
}
else
{
send_file_to_browser($attachment, $display_cat);
}
file_gc();
} }
file_gc();
} }
} }
} }