@@ -148,6 +148,15 @@ public static function javascriptErrorHandler($errorType, $errorMessage)
148
148
die ("<script language='javascript'>parent.ajaxplorer.displayMessage('ERROR', ' " .str_replace ("' " , "\' " , $ errorMessage )."');</script> " );
149
149
}
150
150
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
+
151
160
/**
152
161
* @static
153
162
* @param string $attachmentName
@@ -157,9 +166,7 @@ public static function javascriptErrorHandler($errorType, $errorMessage)
157
166
*/
158
167
public static function generateAttachmentsHeader (&$ attachmentName , $ dataSize , $ isFile =true , $ gzip =false )
159
168
{
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 );
163
170
164
171
header ("Content-Type: application/force-download; name= \"" .$ attachmentName ."\"" );
165
172
header ("Content-Transfer-Encoding: binary " );
@@ -197,6 +204,8 @@ public static function generateAttachmentsHeader(&$attachmentName, $dataSize, $i
197
204
198
205
public static function generateInlineHeaders ($ attachName , $ fileSize , $ mimeType )
199
206
{
207
+ $ attachName = self ::encodeAttachmentName ($ attachName );
208
+
200
209
//Send headers
201
210
header ("Content-Type: " . $ mimeType . "; name= \"" . $ attachName . "\"" );
202
211
header ("Content-Disposition: inline; filename= \"" . $ attachName . "\"" );
0 commit comments