Skip to content
This repository was archived by the owner on Nov 25, 2020. It is now read-only.

Commit c8b12e1

Browse files
committed
Follow-up for filename encoding for attachment headers and IE.
1 parent d641046 commit c8b12e1

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

core/src/core/classes/class.HTMLWriter.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,15 @@ public static function javascriptErrorHandler($errorType, $errorMessage)
148148
die("<script language='javascript'>parent.ajaxplorer.displayMessage('ERROR', '".str_replace("'", "\'", $errorMessage)."');</script>");
149149
}
150150

151+
public static function encodeAttachmentName($name){
152+
if (preg_match('/ MSIE /',$_SERVER['HTTP_USER_AGENT'])
153+
|| preg_match('/ WebKit /',$_SERVER['HTTP_USER_AGENT'])
154+
|| preg_match('/ Trident/',$_SERVER['HTTP_USER_AGENT'])) {
155+
$name = str_replace("+", " ", urlencode(SystemTextEncoding::toUTF8($name)));
156+
}
157+
return $name;
158+
}
159+
151160
/**
152161
* @static
153162
* @param string $attachmentName
@@ -157,9 +166,7 @@ public static function javascriptErrorHandler($errorType, $errorMessage)
157166
*/
158167
public static function generateAttachmentsHeader(&$attachmentName, $dataSize, $isFile=true, $gzip=false)
159168
{
160-
if (preg_match('/ MSIE /',$_SERVER['HTTP_USER_AGENT']) || preg_match('/ WebKit /',$_SERVER['HTTP_USER_AGENT']) || preg_match(‘/ Trident/’,$_SERVER[‘HTTP_USER_AGENT’])) {
161-
$attachmentName = str_replace("+", " ", urlencode(SystemTextEncoding::toUTF8($attachmentName)));
162-
}
169+
$attachmentName = self::encodeAttachmentName($attachmentName);
163170

164171
header("Content-Type: application/force-download; name=\"".$attachmentName."\"");
165172
header("Content-Transfer-Encoding: binary");
@@ -197,6 +204,8 @@ public static function generateAttachmentsHeader(&$attachmentName, $dataSize, $i
197204

198205
public static function generateInlineHeaders($attachName, $fileSize, $mimeType)
199206
{
207+
$attachName = self::encodeAttachmentName($attachName);
208+
200209
//Send headers
201210
header("Content-Type: " . $mimeType . "; name=\"" . $attachName . "\"");
202211
header("Content-Disposition: inline; filename=\"" . $attachName . "\"");

0 commit comments

Comments
 (0)