From: pdontthink Date: Fri, 18 Mar 2005 23:41:42 +0000 (+0000) Subject: Making mailto: conversion in magicHTML() optional (defaults to ON) X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=commitdiff_plain;h=1814c39b2c67433775174accce117c9fe550ea31 Making mailto: conversion in magicHTML() optional (defaults to ON) git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@9068 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/functions/mime.php b/functions/mime.php index 76faea0a..6541820e 100644 --- a/functions/mime.php +++ b/functions/mime.php @@ -1843,9 +1843,14 @@ function sq_sanitize($body, * * @param $body the body of the message * @param $id the id of the message +* @param $message +* @param $mailbox +* @param boolean $take_mailto_links When TRUE, converts mailto: links +* into internal SM compose links +* (optional; default = TRUE) * @return a string with html safe to display in the browser. */ -function magicHTML($body, $id, $message, $mailbox = 'INBOX') { +function magicHTML($body, $id, $message, $mailbox = 'INBOX', $take_mailto_links = true) { require_once(SM_PATH . 'functions/url_parser.php'); // for $MailTo_PReg_Match @@ -2004,49 +2009,51 @@ function magicHTML($body, $id, $message, $mailbox = 'INBOX') { // right: we need a better filtering implementation; adding this randomly // here is not a great solution // - // parseUrl($trusted); // this even parses URLs inside of tags... too aggressive - global $MailTo_PReg_Match; - $MailTo_PReg_Match = '/mailto:' . substr($MailTo_PReg_Match, 1); - if ((preg_match_all($MailTo_PReg_Match, $trusted, $regs)) && ($regs[0][0] != '')) { - foreach ($regs[0] as $i => $mailto_before) { - $mailto_params = $regs[10][$i]; - - // get rid of any tailing quote since we have to add send_to to the end - // - if (substr($mailto_before, strlen($mailto_before) - 1) == '"') - $mailto_before = substr($mailto_before, 0, strlen($mailto_before) - 1); - if (substr($mailto_params, strlen($mailto_params) - 1) == '"') - $mailto_params = substr($mailto_params, 0, strlen($mailto_params) - 1); - - if ($regs[1][$i]) { //if there is an email addr before '?', we need to merge it with the params - $to = 'to=' . $regs[1][$i]; - if (strpos($mailto_params, 'to=') > -1) //already a 'to=' - $mailto_params = str_replace('to=', $to . '%2C%20', $mailto_params); - else { - if ($mailto_params) //already some params, append to them - $mailto_params .= '&' . $to; - else - $mailto_params .= '?' . $to; + if ($take_mailto_links) { + // parseUrl($trusted); // this even parses URLs inside of tags... too aggressive + global $MailTo_PReg_Match; + $MailTo_PReg_Match = '/mailto:' . substr($MailTo_PReg_Match, 1); + if ((preg_match_all($MailTo_PReg_Match, $trusted, $regs)) && ($regs[0][0] != '')) { + foreach ($regs[0] as $i => $mailto_before) { + $mailto_params = $regs[10][$i]; + + // get rid of any tailing quote since we have to add send_to to the end + // + if (substr($mailto_before, strlen($mailto_before) - 1) == '"') + $mailto_before = substr($mailto_before, 0, strlen($mailto_before) - 1); + if (substr($mailto_params, strlen($mailto_params) - 1) == '"') + $mailto_params = substr($mailto_params, 0, strlen($mailto_params) - 1); + + if ($regs[1][$i]) { //if there is an email addr before '?', we need to merge it with the params + $to = 'to=' . $regs[1][$i]; + if (strpos($mailto_params, 'to=') > -1) //already a 'to=' + $mailto_params = str_replace('to=', $to . '%2C%20', $mailto_params); + else { + if ($mailto_params) //already some params, append to them + $mailto_params .= '&' . $to; + else + $mailto_params .= '?' . $to; + } } + + $url_str = preg_replace(array('/to=/i', '/(?