Aleksander Machniak
2016-05-22 0344b168276f80189e2254c75a762aff5b517b6b
program/include/rcmail_string_replacer.php
@@ -1,11 +1,11 @@
<?php
/*
/**
 +-----------------------------------------------------------------------+
 | program/include/rcmail_string_replacer.php                            |
 |                                                                       |
 | This file is part of the Roundcube Webmail client                     |
 | Copyright (C) 2012, The Roundcube Dev Team                            |
 | Copyright (C) 2012-2013, The Roundcube Dev Team                       |
 |                                                                       |
 | Licensed under the GNU General Public License version 3 or            |
 | any later version with exceptions for skins & plugins.                |
@@ -19,12 +19,11 @@
 +-----------------------------------------------------------------------+
*/
/**
 * Helper class for turning URLs and email addresses in plaintext content
 * into clickable links.
 *
 * @package    Core
 * @package Webmail
 * @subpackage Utils
 */
class rcmail_string_replacer extends rcube_string_replacer
@@ -40,15 +39,25 @@
     */
    public function mailto_callback($matches)
    {
      $href   = $matches[1];
      $suffix = $this->parse_url_brackets($href);
        $href   = $matches[1];
        $suffix = $this->parse_url_brackets($href);
        $email  = $href;
      $i = $this->add(html::a(array(
          'href' => 'mailto:' . $href,
          'onclick' => "return ".rcmail_output::JS_OBJECT_NAME.".command('compose','".rcube::JQ($href)."',this)",
        ), rcube::Q($href)) . $suffix);
        if (strpos($email, '?')) {
            list($email,) = explode('?', $email);
        }
      return $i >= 0 ? $this->get_replacement($i) : '';
        // skip invalid emails
        if (!rcube_utils::check_email($email, false)) {
            return $matches[1];
        }
        $i = $this->add(html::a(array(
            'href'    => 'mailto:' . $href,
            'onclick' => "return ".rcmail_output::JS_OBJECT_NAME.".command('compose','".rcube::JQ($href)."',this)",
            ),
            rcube::Q($href)) . $suffix);
        return $i >= 0 ? $this->get_replacement($i) : '';
    }
}
}