• R/O
  • SSH
  • HTTPS

fswiki: Commit


Commit MetaInfo

Revision178 (tree)
Time2017-12-08 17:34:18
Authorkgsoft

Log Message

BugTrack-wiki/347 : ダウンロードファイル名の文字化け対応

Change Summary

Incremental Difference

--- fswiki/trunk/fswiki/lib/Util.pm (revision 177)
+++ fswiki/trunk/fswiki/lib/Util.pm (revision 178)
@@ -520,9 +520,12 @@
520520 my $mtime = (stat($lock))[9];
521521 rmdir($lock) if($mtime < time() - 60);
522522 }
523+ #ディレクトリ名の長さ取得
524+ my $to_long = 0;
525+ $to_long = 1 if (length($lock) > 250);
523526
524527 while(!mkdir($lock,0777)){
525- die "Lock is busy." if(--$retry <= 0);
528+ die "Lock is busy".($to_long ? ' or long filename' : '')."." if(--$retry <= 0);
526529 sleep(1);
527530 }
528531 }
@@ -690,7 +693,10 @@
690693 sub make_content_disposition {
691694 my ($filename, $disposition) = @_;
692695 my $ua = $ENV{"HTTP_USER_AGENT"};
693- my $encoded = ($ua =~ /MSIE/ ? &Jcode::convert($filename, 'sjis') : Jcode->new($filename)->mime_encode(''));
696+ eval("use MIME::Base64;");
697+ my $encoded = ( $ua =~ /MSIE|Trident/i ? Jcode->new($filename)->sjis
698+ : $ua =~ /Chrome|Firefox/i ? "=?utf-8?B?".MIME::Base64::encode_base64(Jcode->new($filename)->utf8,'')."?="
699+ : Jcode->new($filename)->utf8 );
694700 return "Content-Disposition: $disposition;filename=\"".$encoded."\"\n\n";
695701 }
696702
Show on old repository browser