From 736fe94bac03a5dc7e11d015dc83a83d095f00b1 Mon Sep 17 00:00:00 2001 From: popcorner <351633+popcorner@user.noreply.gitee.com> Date: Fri, 5 Feb 2021 06:07:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E9=83=A8=E5=88=86?= =?UTF-8?q?=E5=9C=BA=E6=99=AF=E4=B8=8B=E4=B8=8B=E8=BD=BD=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=90=8D=E5=87=BA=E9=94=99=E5=8F=8A=E4=B8=8D=E7=AC=A6=E5=90=88?= =?UTF-8?q?=E6=A0=87=E5=87=86=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- upload/source/include/portalcp/portalcp_diy.php | 2 +- upload/source/include/spacecp/spacecp_pm.php | 4 ++-- upload/source/module/forum/forum_attachment.php | 6 +++--- upload/source/module/forum/forum_misc.php | 8 ++------ upload/source/module/misc/misc_stat.php | 3 ++- upload/source/module/portal/portal_attachment.php | 4 ++-- 6 files changed, 12 insertions(+), 15 deletions(-) diff --git a/upload/source/include/portalcp/portalcp_diy.php b/upload/source/include/portalcp/portalcp_diy.php index e048b3722..cd7899459 100644 --- a/upload/source/include/portalcp/portalcp_diy.php +++ b/upload/source/include/portalcp/portalcp_diy.php @@ -275,7 +275,7 @@ if($op == 'blockclass') { $str = serialize($diycontent); dheader('Content-Length: '.strlen($str)); dheader('Content-Disposition: attachment; filename='.$filename.'.txt'); - dheader('Content-Type: text/plant'); + dheader('Content-Type: text/plain'); } else { require_once libfile('class/xml'); $str = array2xml($diycontent, true); diff --git a/upload/source/include/spacecp/spacecp_pm.php b/upload/source/include/spacecp/spacecp_pm.php index fcce61803..3daa15cc1 100644 --- a/upload/source/include/spacecp/spacecp_pm.php +++ b/upload/source/include/spacecp/spacecp_pm.php @@ -501,12 +501,12 @@ if($_GET['op'] == 'checknewpm') { $contents = nl2br($contents); $filesize = strlen($contents); - $filename = '"'.(strtolower(CHARSET) == 'utf-8' && (strexists($_SERVER['HTTP_USER_AGENT'], 'MSIE') || strexists($_SERVER['HTTP_USER_AGENT'], 'Trident') || strexists($_SERVER['HTTP_USER_AGENT'], 'Edge')) ? urlencode($filename) : $filename).'"'; + $filenameencode = strtolower(CHARSET) == 'utf-8' ? rawurlencode($filename) : rawurlencode(diconv($filename, CHARSET, 'UTF-8')); dheader('Date: '.gmdate('D, d M Y H:i:s', $val['dateline']).' GMT'); dheader('Last-Modified: '.gmdate('D, d M Y H:i:s', $val['dateline']).' GMT'); dheader('Content-Encoding: none'); - dheader('Content-Disposition: attachment; filename='.$filename); + dheader('Content-Disposition: attachment; filename="'.(($filename == $filenameencode) ? $filename.'"' : $filenameencode.'"; filename*=utf-8\'\''.$filenameencode)); dheader('Content-Type: application/octet-stream'); dheader('Content-Length: '.$filesize); diff --git a/upload/source/module/forum/forum_attachment.php b/upload/source/module/forum/forum_attachment.php index 76130bcd8..8277a1242 100644 --- a/upload/source/module/forum/forum_attachment.php +++ b/upload/source/module/forum/forum_attachment.php @@ -244,16 +244,16 @@ $mimetype = ext_to_mimetype($attach['filename']); $filesize = !$attach['remote'] ? filesize($filename) : $attach['filesize']; // 如果range_end没有传入,更新range_end if ($has_range_header && !$range_end) $range_end = $filesize - 1; -$attach['filename'] = '"'.(strtolower(CHARSET) == 'utf-8' && (strexists($_SERVER['HTTP_USER_AGENT'], 'MSIE') || strexists($_SERVER['HTTP_USER_AGENT'], 'Trident') || strexists($_SERVER['HTTP_USER_AGENT'], 'Edge')) ? urlencode($attach['filename']) : $attach['filename']).'"'; +$filenameencode = strtolower(CHARSET) == 'utf-8' ? rawurlencode($attach['filename']) : rawurlencode(diconv($attach['filename'], CHARSET, 'UTF-8')); dheader('Date: '.gmdate('D, d M Y H:i:s', $attach['dateline']).' GMT'); dheader('Last-Modified: '.gmdate('D, d M Y H:i:s', $attach['dateline']).' GMT'); dheader('Content-Encoding: none'); if($isimage && !empty($_GET['noupdate']) || !empty($_GET['request'])) { - dheader('Content-Disposition: inline; filename='.$attach['filename']); + dheader('Content-Disposition: inline; filename="'.(($attach['filename'] == $filenameencode) ? $attach['filename'].'"' : $filenameencode.'"; filename*=utf-8\'\''.$filenameencode)); } else { - dheader('Content-Disposition: attachment; filename='.$attach['filename']); + dheader('Content-Disposition: attachment; filename="'.(($attach['filename'] == $filenameencode) ? $attach['filename'].'"' : $filenameencode.'"; filename*=utf-8\'\''.$filenameencode)); } if($isimage) { dheader('Content-Type: image'); diff --git a/upload/source/module/forum/forum_misc.php b/upload/source/module/forum/forum_misc.php index 9e5ab49ce..342b65ed5 100644 --- a/upload/source/module/forum/forum_misc.php +++ b/upload/source/module/forum/forum_misc.php @@ -425,13 +425,9 @@ IconIndex=1 $filename = $_G['setting']['bbname'].'.url'; } - if(!(strexists($_SERVER['HTTP_USER_AGENT'], 'MSIE') || strexists($_SERVER['HTTP_USER_AGENT'], 'Trident') || strexists($_SERVER['HTTP_USER_AGENT'], 'Edge'))) { - $filename = diconv($filename, CHARSET, 'UTF-8'); - } else { - $filename = diconv($filename, CHARSET, 'GBK'); - } + $filenameencode = strtolower(CHARSET) == 'utf-8' ? rawurlencode($filename) : rawurlencode(diconv($filename, CHARSET, 'UTF-8')); dheader('Content-type: application/octet-stream'); - dheader('Content-Disposition: attachment; filename="'.$filename.'"'); + dheader('Content-Disposition: attachment; filename="'.(($filename == $filenameencode) ? $filename.'"' : $filenameencode.'"; filename*=utf-8\'\''.$filenameencode)); echo $shortcut; exit; } elseif($_GET['action'] == 'livelastpost') { diff --git a/upload/source/module/misc/misc_stat.php b/upload/source/module/misc/misc_stat.php index 8aa95345d..fb5241bc6 100644 --- a/upload/source/module/misc/misc_stat.php +++ b/upload/source/module/misc/misc_stat.php @@ -42,12 +42,13 @@ if($op == 'basic') { extract($statvars); if($_GET['exportexcel']) { $filename = 'stat_modworks_'.($username ? $username.'_' : '').$starttime.'_'.$endtime.'.csv'; + $filenameencode = strtolower(CHARSET) == 'utf-8' ? rawurlencode($filename) : rawurlencode(diconv($filename, CHARSET, 'UTF-8')); include template('forum/stat_misc_export'); $csvstr = ob_get_contents(); ob_end_clean(); header('Content-Encoding: none'); header('Content-Type: application/octet-stream'); - header('Content-Disposition: attachment; filename='.$filename); + header('Content-Disposition: attachment; filename="'.(($filename == $filenameencode) ? $filename.'"' : $filenameencode.'"; filename*=utf-8\'\''.$filenameencode)); header('Pragma: no-cache'); header('Expires: 0'); if($_G['charset'] != 'gbk') { diff --git a/upload/source/module/portal/portal_attachment.php b/upload/source/module/portal/portal_attachment.php index cf0b9a22a..d173d2929 100644 --- a/upload/source/module/portal/portal_attachment.php +++ b/upload/source/module/portal/portal_attachment.php @@ -62,12 +62,12 @@ if($operation == 'delete') { } $filesize = $attach['filesize']; - $attach['filename'] = '"'.(strtolower(CHARSET) == 'utf-8' && (strexists($_SERVER['HTTP_USER_AGENT'], 'MSIE') || strexists($_SERVER['HTTP_USER_AGENT'], 'Trident') || strexists($_SERVER['HTTP_USER_AGENT'], 'Edge')) ? urlencode($attach['filename']) : $attach['filename']).'"'; + $filenameencode = strtolower(CHARSET) == 'utf-8' ? rawurlencode($attach['filename']) : rawurlencode(diconv($attach['filename'], CHARSET, 'UTF-8')); dheader('Date: '.gmdate('D, d M Y H:i:s', $attach['dateline']).' GMT'); dheader('Last-Modified: '.gmdate('D, d M Y H:i:s', $attach['dateline']).' GMT'); dheader('Content-Encoding: none'); - dheader('Content-Disposition: attachment; filename='.$attach['filename']); + dheader('Content-Disposition: attachment; filename="'.(($attach['filename'] == $filenameencode) ? $attach['filename'].'"' : $filenameencode.'"; filename*=utf-8\'\''.$filenameencode)); dheader('Content-Type: '.$attach['filetype']); dheader('Content-Length: '.$filesize); -- Gitee