Changeset d487cd5a in github for program/steps/mail/get.inc


Ignore:
Timestamp:
May 30, 2012 6:17:26 AM (12 months ago)
Author:
Aleksander Machniak <alec@…>
Branches:
master, HEAD, pdo
Children:
528c78a
Parents:
ca1c2a8 (diff), 19cc5b9 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'dev-browser-capabilities'

Conflicts:

CHANGELOG

File:
1 edited

Legend:

Unmodified
Added
Removed
  • program/steps/mail/get.inc

    r041c93c r19cc5b9  
    2323// show loading page 
    2424if (!empty($_GET['_preload'])) { 
    25   $url = preg_replace('/[&?]+_preload=1/', '', $_SERVER['REQUEST_URI']); 
     25  $url = preg_replace('/([&?]+)_preload=/', '\\1_embed=', $_SERVER['REQUEST_URI']); 
    2626  $message = rcube_label('loadingdata'); 
    2727 
     
    7777    // overwrite modified vars from plugin 
    7878    $mimetype = $plugin['mimetype']; 
     79 
     80    // TIFF to JPEG conversion, if needed 
     81    $tiff_support = !empty($_SESSION['browser_caps']) && !empty($_SESSION['browser_caps']['tif']); 
     82    if (!empty($_REQUEST['_embed']) && !$tiff_support 
     83      && $RCMAIL->config->get('im_convert_path') 
     84      && rcmail_part_image_type($part) == 'image/tiff' 
     85    ) { 
     86      $tiff2jpeg = true; 
     87      $mimetype = 'image/jpeg'; 
     88    } 
     89 
    7990    list($ctype_primary, $ctype_secondary) = explode('/', $mimetype); 
    8091    if ($plugin['body']) 
     
    151162      header("Content-Disposition: $disposition; filename=\"$filename\""); 
    152163 
     164      // handle tiff to jpeg conversion 
     165      if (!empty($tiff2jpeg)) { 
     166        $temp_dir  = unslashify($RCMAIL->config->get('temp_dir')); 
     167        $file_path = tempnam($temp_dir, 'rcmAttmnt'); 
     168 
     169        // write content to temp file 
     170        if ($part->body) { 
     171          $saved = file_put_contents($file_path, $part->body); 
     172        } 
     173        else if ($part->size) { 
     174          $fd = fopen($file_path, 'w'); 
     175          $saved = $RCMAIL->storage->get_message_part($MESSAGE->uid, $part->mime_id, $part, false, $fd); 
     176          fclose($fd); 
     177        } 
     178 
     179        // convert image to jpeg and send it to the browser 
     180        if ($saved) { 
     181          $image = new rcube_image($file_path); 
     182          if ($image->convert(rcube_image::TYPE_JPG, $file_path)) { 
     183            header("Content-Length: " . filesize($file_path)); 
     184            readfile($file_path); 
     185          } 
     186          unlink($file_path); 
     187        } 
     188      } 
    153189      // do content filtering to avoid XSS through fake images 
    154       if (!empty($_REQUEST['_embed']) && $browser->ie && $browser->ver <= 8) { 
     190      else if (!empty($_REQUEST['_embed']) && $browser->ie && $browser->ver <= 8) { 
    155191        if ($part->body) { 
    156192          echo preg_match('/<(script|iframe|object)/i', $part->body) ? '' : $part->body; 
Note: See TracChangeset for help on using the changeset viewer.