Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 61dca5d3

Von Tamino Steinert vor 3 Monaten hinzugefügt

  • ID 61dca5d346d9931a2665152049b9784adc83a9f0
  • Vorgänger de68b5b2
  • Nachfolger 014942ea

EmailJournal: bei 'application/octet-stream' versuche mime-Typ zu raten

Unterschiede anzeigen:

SL/Controller/EmailJournal.pm
32 32

  
33 33
use List::Util qw(first);
34 34
use List::MoreUtils qw(any);
35
use File::MimeInfo::Magic;
35 36

  
36 37
use Rose::Object::MakeMethods::Generic
37 38
(
......
326 327
    $::form->error(t8('You do not have permission to access this entry.'));
327 328
  }
328 329

  
330
  my $mime_type = $attachment->mime_type;
331
  if ($mime_type eq 'application/octet-stream') {
332
    # try to guess the mime_type
333
    if ($attachment->content =~ m/^%PDF/) {
334
      $mime_type = 'application/pdf';
335
    } else {
336
      $mime_type = File::MimeInfo::Magic::mimetype($attachment->name);
337
      $mime_type = 'text/plain' if $mime_type eq 'application/octet-stream';
338
    }
339
  }
340

  
329 341
  return $self->send_file(
330 342
    \$attachment->content,
331 343
    name => $attachment->name,
332
    type => $attachment->mime_type,
344
    type => $mime_type,
333 345
    content_disposition => 'inline',
334 346
  );
335 347
}

Auch abrufbar als: Unified diff