diff options
author | Aleksander Machniak <alec@alec.pl> | 2015-01-12 05:44:28 -0500 |
---|---|---|
committer | Aleksander Machniak <alec@alec.pl> | 2015-01-12 05:44:28 -0500 |
commit | c6efcf5e6d11a0f236daff3aa3bd6532c77726d3 (patch) | |
tree | 7135cf595e0489d2640ac72d48a53b6ac408078d /program/steps | |
parent | 49b1c16c464586d826e974cd2223090923207516 (diff) |
Fix blocked.gif image usage with assets_dir set
Diffstat (limited to 'program/steps')
-rw-r--r-- | program/steps/mail/compose.inc | 26 | ||||
-rw-r--r-- | program/steps/mail/func.inc | 2 | ||||
-rw-r--r-- | program/steps/mail/get.inc | 4 |
3 files changed, 24 insertions, 8 deletions
diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc index 20a27ecb0..d4db232ea 100644 --- a/program/steps/mail/compose.inc +++ b/program/steps/mail/compose.inc @@ -781,12 +781,13 @@ function rcmail_prepare_message_body() unset($plugin); // add blocked.gif attachment (#1486516) - if ($isHtml && preg_match('#<img src="\./program/resources/blocked\.gif"#', $body)) { - if ($attachment = rcmail_save_image('program/resources/blocked.gif', 'image/gif')) { + if ($isHtml && preg_match('#<img src="program/resources/blocked\.gif"#', $body)) { + $content = $RCMAIL->get_resource_content('blocked.gif'); + if ($content && ($attachment = rcmail_save_image('blocked.gif', 'image/gif', $content))) { $COMPOSE['attachments'][$attachment['id']] = $attachment; $url = sprintf('%s&_id=%s&_action=display-attachment&_file=rcmfile%s', $RCMAIL->comm_path, $COMPOSE['id'], $attachment['id']); - $body = preg_replace('#\./program/resources/blocked\.gif#', $url, $body); + $body = preg_replace('#program/resources/blocked\.gif#', $url, $body); } } @@ -1400,18 +1401,31 @@ function rcmail_save_attachment(&$message, $pid) return false; } -function rcmail_save_image($path, $mimetype='') +function rcmail_save_image($path, $mimetype = '', $data = null) { global $COMPOSE; // handle attachments in memory - $data = file_get_contents($path); + if (empty($data)) { + $data = file_get_contents($path); + $is_file = true; + } + $name = rcmail_basename($path); + if (empty($mimetype)) { + if ($is_file) { + $mimetype = rcube_mime::file_content_type($path, $name); + } + else { + $mimetype = rcube_mime::file_content_type($data, $name, 'application/octet-stream', true); + } + } + $attachment = array( 'group' => $COMPOSE['id'], 'name' => $name, - 'mimetype' => $mimetype ? $mimetype : rcube_mime::file_content_type($path, $name), + 'mimetype' => $mimetype, 'data' => $data, 'size' => strlen($data), ); diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc index 6423636f0..48d989954 100644 --- a/program/steps/mail/func.inc +++ b/program/steps/mail/func.inc @@ -815,7 +815,7 @@ function rcmail_wash_html($html, $p, $cid_replaces) $wash_opts = array( 'show_washed' => false, 'allow_remote' => $p['safe'], - 'blocked_src' => "./program/resources/blocked.gif", + 'blocked_src' => 'program/resources/blocked.gif', 'charset' => RCUBE_CHARSET, 'cid_map' => $cid_replaces, 'html_elements' => array('body'), diff --git a/program/steps/mail/get.inc b/program/steps/mail/get.inc index 775349d1c..150737a83 100644 --- a/program/steps/mail/get.inc +++ b/program/steps/mail/get.inc @@ -183,10 +183,12 @@ else if (strlen($part_id)) { // send blocked.gif for expected images if (empty($_REQUEST['_mimewarning']) && strpos($mimetype, 'image/') === 0) { // Do not cache. Failure might be the result of a misconfiguration, thus real content should be returned once fixed. + $content = $RCMAIL->get_resource_content('blocked.gif'); $OUTPUT->nocacheing_headers(); header("Content-Type: image/gif"); header("Content-Transfer-Encoding: binary"); - readfile(INSTALL_PATH . 'program/resources/blocked.gif'); + header("Content-Length: " . strlen($content)); + echo $content; } else { // html warning with a button to load the file anyway $OUTPUT = new rcmail_html_page(); |