BugTrack-wiki/347 : ダウンロードファイル名の文字化け対応
@@ -520,9 +520,12 @@ | ||
520 | 520 | my $mtime = (stat($lock))[9]; |
521 | 521 | rmdir($lock) if($mtime < time() - 60); |
522 | 522 | } |
523 | + #ディレクトリ名の長さ取得 | |
524 | + my $to_long = 0; | |
525 | + $to_long = 1 if (length($lock) > 250); | |
523 | 526 | |
524 | 527 | 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); | |
526 | 529 | sleep(1); |
527 | 530 | } |
528 | 531 | } |
@@ -690,7 +693,10 @@ | ||
690 | 693 | sub make_content_disposition { |
691 | 694 | my ($filename, $disposition) = @_; |
692 | 695 | 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 ); | |
694 | 700 | return "Content-Disposition: $disposition;filename=\"".$encoded."\"\n\n"; |
695 | 701 | } |
696 | 702 |