diff options
| author | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2009-01-15 18:24:38 +0000 |
|---|---|---|
| committer | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2009-01-15 18:24:38 +0000 |
| commit | 9e54807c8de8e118c30769b3a35e3cb70c679e08 (patch) | |
| tree | b340d6a1cf8461aa710ea56efd026046dae98484 /roundcubemail/program | |
| parent | e42638813007db327a9d5d98e3adc663cce05502 (diff) | |
- Allow absolute URLs to images in HTML messages/sigs (#1485666)
- Fix message body which contains both inline attachments and emotions
git-svn-id: https://svn.roundcube.net/trunk@2232 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'roundcubemail/program')
| -rw-r--r-- | roundcubemail/program/js/editor.js | 4 | ||||
| -rw-r--r-- | roundcubemail/program/steps/mail/sendmail.inc | 50 |
2 files changed, 27 insertions, 27 deletions
diff --git a/roundcubemail/program/js/editor.js b/roundcubemail/program/js/editor.js index a3f0d3492..624509085 100644 --- a/roundcubemail/program/js/editor.js +++ b/roundcubemail/program/js/editor.js @@ -28,6 +28,8 @@ function rcmail_editor_init(skin_path, editor_lang, spellcheck, mode) theme_advanced_buttons1 : 'bold,italic,underline,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,separator,outdent,indent,charmap,hr,link,unlink,code,forecolor', theme_advanced_buttons2 : ',fontselect,fontsizeselect', theme_advanced_buttons3 : '', + relative_urls : false, + remove_script_host : false, gecko_spellcheck : true }); else // mail compose @@ -49,6 +51,8 @@ function rcmail_editor_init(skin_path, editor_lang, spellcheck, mode) external_image_list_url : 'program/js/editor_images.js', spellchecker_languages : (rcmail.env.spellcheck_langs ? rcmail.env.spellcheck_langs : 'Dansk=da,Deutsch=de,+English=en,Espanol=es,Francais=fr,Italiano=it,Nederlands=nl,Polski=pl,Portugues=pt,Suomi=fi,Svenska=sv'), gecko_spellcheck : true, + relative_urls : false, + remove_script_host : false , rc_client: rcube_webmail_client, oninit : 'rcmail_editor_callback' }); diff --git a/roundcubemail/program/steps/mail/sendmail.inc b/roundcubemail/program/steps/mail/sendmail.inc index b065c2a25..5f12f3fe9 100644 --- a/roundcubemail/program/steps/mail/sendmail.inc +++ b/roundcubemail/program/steps/mail/sendmail.inc @@ -98,47 +98,43 @@ function rcmail_attach_emoticons(&$mime_message) { global $CONFIG; - $htmlContents = $mime_message->getHtmlBody(); + $body = $mime_message->getHtmlBody(); // remove any null-byte characters before parsing - $body = preg_replace('/\x00/', '', $htmlContents); + $body = preg_replace('/\x00/', '', $body); - $last_img_pos = 0; $searchstr = 'program/js/tiny_mce/plugins/emotions/img/'; - $path_len = strlen(INSTALL_PATH . '/'); + $offset = 0; // keep track of added images, so they're only added once $included_images = array(); - // find emoticon image tags - while ($pos = strpos($body, $searchstr, $last_img_pos)) - { - $pos2 = strpos($body, '"', $pos); - $body_pre = substr($body, 0, $pos); - $body_post = substr($body, $pos2); + if (preg_match_all('# src=[\'"]([^\'"]+)#', $body, $matches, PREG_OFFSET_CAPTURE)) { + foreach ($matches[1] as $m) { + // find emoticon image tags + if (preg_match('#'.$searchstr.'(.*)$#', $m[0], $imatches)) { + $image_name = $imatches[1]; - $image_name = substr($body, - $pos + strlen($searchstr), - $pos2 - ($pos + strlen($searchstr))); + // sanitize image name so resulting attachment doesn't leave images dir + $image_name = preg_replace('/[^a-zA-Z0-9_\.\-]/i', '', $image_name); + $img_file = INSTALL_PATH . '/' . $searchstr . $image_name; - // sanitize image name so resulting attachment doesn't leave images dir - $image_name = preg_replace('/[^a-zA-Z0-9_\.\-]/i','',$image_name); - $img_file = INSTALL_PATH . '/' . $searchstr . $image_name; + if (! in_array($image_name, $included_images)) { + // add the image to the MIME message + if(! $mime_message->addHTMLImage($img_file, 'image/gif', '', true, $image_name)) + $OUTPUT->show_message("emoticonerror", 'error'); + array_push($included_images, $image_name); + } - if (! in_array($image_name, $included_images)) - { - // add the image to the MIME message - if(! $mime_message->addHTMLImage($img_file, 'image/gif', '', true, $image_name)) - $OUTPUT->show_message("emoticonerror", 'error'); - array_push($included_images, $image_name); + $body = substr_replace($body, $img_file, $m[1] + $offset, strlen($m[0])); + $offset += strlen($img_file) - strlen($m[0]); } - - $body = $body_pre . $img_file . $body_post; - - $last_img_pos = $pos2 + $path_len; } + } $mime_message->setHTMLBody($body); + + return $body; } @@ -276,7 +272,7 @@ if ($isHtml) $MAIL_MIME->setTXTBody($plainTextPart); // look for "emoticon" images from TinyMCE and copy into message as attachments - rcmail_attach_emoticons($MAIL_MIME); + $message_body = rcmail_attach_emoticons($MAIL_MIME); } else { |
