Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 014942ea

Von Tamino Steinert vor 2 Monaten hinzugefügt

  • ID 014942eaaa67edf5c310d70f4c332768a2a338b2
  • Vorgänger 61dca5d3
  • Nachfolger 36f031f5

EmailJournal: zeige nur Standarddateiformate in Dateivorschau

Unterschiede anzeigen:

SL/Controller/EmailJournal.pm
327 327
    $::form->error(t8('You do not have permission to access this entry.'));
328 328
  }
329 329

  
330
  my $name = $attachment->name;
331
  my $content = \$attachment->content;
330 332
  my $mime_type = $attachment->mime_type;
333

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

  
344
  # only show standard types
345
  if (!any {$mime_type =~ m/^\Q$_\E/} qw(
346
    text/plain text/xml image/png image/jpeg
347
    application/pdf application/json application/xml
348
    )) {
349
    $content = \t8("Can't display file")->translated;
350
    $name = '';
351
    $mime_type = 'text/plain';
352
  }
353

  
341 354
  return $self->send_file(
342
    \$attachment->content,
343
    name => $attachment->name,
355
    $content,
356
    name => $name,
344 357
    type => $mime_type,
345 358
    content_disposition => 'inline',
346 359
  );

Auch abrufbar als: Unified diff