> >>>>>>> On Monday, December 25, 2006, Pål wrote: > >>>>>>>> I have a helpdesk system which sends out mail. Some of the mail > >>>>>>>> contains a mailto link like this one: > >>>>>>> > >>>>>>>> For status on your request, click the link below: > >>>>>>>> mailto:helpdesk@xxxxxxxxxxxx?subject=Status&body=52667668 > >>>>>>> > >>>>>>>> Squirrelmail will not make the link correct, as only > >>>>>>>> helpdesk@xxxxxxxxxxxx is recognised and not the subject info. > >>>>>>>> When > >>>>>>>> the reader clicks the link the address helpdesk@xxxxxxxxxxxx > >>>>>>>> is put > >>>>>>>> in the TO-field, but the subject is missing. > >>>>>>> > >>>>>>>> Anyone who knows how to fix this? > >>>>>>> > >>>>>>>> Running SM 1.4.4.1 > >>>>>>> > >>>>>>>> I guess the helpdesk system is badly written as it expects > >>>>>>>> mail to > >>>>>>>> be read in Outlook, and not web mail readers like SM. > >>>>>>> > >>>>>>> I believe the specs say that subject, is allowed, not sure on > >>>>>>> body > >>>>>>> though. If you upgrade to 1.4.9a, and try again, this should > >>>>>>> work, at > >>>>>>> least the subject. An upgrade should be in order anyway as > >>>>>>> 1.4.4 is > >>>>>>> known to have security issues. > >>>>>>> > >>>>>>> > >>>>>> > >>>>>> I have the same problem with version 1.4.11 > >>>>> > >>>>> Thanks for the report. The mailto: functionality was in fact > >>>>> broken > >>>>> again. I just fixed it in 1.4.12 and 1.5.2. You might wait a > >>>>> day and > >>>>> then get a snapshot download of 1.4.12 and it should work > >>>>> again. The > >>>>> instructions on how to make mailto: links work are also updated > >>>>> and > >>>>> hopefully more helpful. See the contrib directory in the > >>>>> SquirrelMail > >>>>> package or this: > >>>>> > >>>>> http://squirrelmail.org/wiki/WindowsMailto > >>>>> > >>>>> If you continue to experience problems, please let us know. > >>>> > >>>> > >>>> > >>>> I have downloaded the version 1.4.12 [SVN] (Checked out revision > >>>> 12786.) but the problem remains. > >>>> See the picture in attachment. > >>>> > >>>> I'm afraid that the problem is not realy related to <http://squirrelmail.org/wiki/WindowsMailto > >>>>> . > >>>> It's interesting to know that we can jump directly to > >>>> SquirrelMail by > >>>> clicking on a mailto link on a web page, but the problem here is > >>>> that > >>>> the mailto link is broken in SquirreMail and because of that if we > >>>> click onto the link, we don't get what we want. > >>>> In the case of the picture, clicking on the first mailto link, > >>>> open a > >>>> compose page whith the recipient but not the subject. > >>> > >>> Looks to me like you are viewing a message in plain text. In such a > >>> format, you will never get more than the email address being > >>> highlighted. If you want a mailto: link to be clickable, you need > >>> to > >>> have a mail sent in HTML format, and make sure you are viewing it in > >>> HTML format yourself. However, currently, that seems to be broken > >>> too. > >> > >> This is now fixed (patch also included below), however, the link is > >> currently displayed as a mailto: link instead of a link to the SM > >> compose screen. I will look at fixing that later. If anyone else > >> can > >> look at it and create a patch, contributions always welcome. > > > > This is now fixed as well. Patch is below (you still need to apply > > the one here that is quoted from my previous email on this thread) > > > > =================================================================== > >> --- branches/SM-1_4-STABLE/squirrelmail/functions/mime.php > >> 2007-11-27 09:12:05 UTC (rev 12787) > >> +++ branches/SM-1_4-STABLE/squirrelmail/functions/mime.php > >> 2007-11-27 11:20:55 UTC (rev 12788) > >> @@ -1704,6 +1704,7 @@ > >> $aUrl = parse_url($attvalue); > >> if (isset($aUrl['scheme'])) { > >> switch(strtolower($aUrl['scheme'])) { > >> + case 'mailto': > >> case 'http': > >> case 'https': > >> case 'ftp': > >> > > > > > > > > > > Index: functions/mime.php > > =================================================================== > > --- functions/mime.php (revision 12788) > > +++ functions/mime.php (working copy) > > @@ -2181,9 +2181,15 @@ > > * > > * @param $body the body of the message > > * @param $id the id of the message > > + * @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 > > + > > global $attachment_common_show_images, $view_unsafe_images, > > $has_unsafe_images; > > /** > > @@ -2335,6 +2341,59 @@ > > if (strpos($trusted,$secremoveimg)){ > > $has_unsafe_images = true; > > } > > + > > + // we want to parse mailto's in HTML output, change to SM > > compose links > > + // this is a modified version of code from url_parser.php... > > but Marc is > > + // right: we need a better filtering implementation; adding > > this randomly > > + // here is not a great solution > > + // > > + 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', > > '/(?<!b)cc=/i', '/bcc=/i'), array('send_to=', 'send_to_cc=', > > 'send_to_bcc='), $mailto_params); > > + > > + // we'll already have target=_blank, no need to allow > > comp_in_new > > + // here (which would be a lot more work anyway) > > + // > > + global $compose_new_win; > > + $temp_comp_in_new = $compose_new_win; > > + $compose_new_win = 0; > > + $comp_uri = makeComposeLink('src/compose.php' . > > $url_str, $mailto_before); > > + $compose_new_win = $temp_comp_in_new; > > + > > + // remove <a href=" and anything after the next > > quote (we only > > + // need the uri, not the link HTML) in compose uri > > + // > > + $comp_uri = substr($comp_uri, 9); > > + $comp_uri = substr($comp_uri, 0, strpos($comp_uri, > > '"', 1)); > > + $trusted = str_replace($mailto_before, $comp_uri, > > $trusted); > > + } > > + } > > + } > > + > > return $trusted; > > } > > > > Index: functions/url_parser.php > > =================================================================== > > --- functions/url_parser.php (revision 12767) > > +++ functions/url_parser.php (working copy) > > @@ -37,6 +37,15 @@ > > $Email_RegExp_Match = '[0-9a-z]([-_.+]?[0-9a-z])*(%' . > > $Host_RegExp_Match . > > ')?@' . $Host_RegExp_Match; > > > > +/** > > + * rfc 2368 (mailto URL) preg_match() regexp > > + * @link http://www.ietf.org/rfc/rfc2368.txt > > + * @global string MailTo_PReg_Match the encapsulated regexp for > > preg_match() > > + */ > > +global $MailTo_PReg_Match; > > +$Mailto_Email_RegExp = '[0-9a-z%]([-_.+%]?[0-9a-z])*(%' . > > $Host_RegExp_Match . ')?@' . $Host_RegExp_Match; > > +$MailTo_PReg_Match = '/((?:' . $Mailto_Email_RegExp . > > ')*)((?:\?(?:to|cc|bcc|subject|body)=[^\s\?&=,()]+)?(?:&(?:to|cc| > > bcc|subject|body)=[^\s\?&=,()]+)*)/i'; > > + > > function parseEmail (&$body) { > > global $color, $Email_RegExp_Match, $compose_new_win; > > $sbody = $body; > > > > hello, > > I have change my configuration to view the messages in HTML by default. > The modifications of the files mime.php and url_parser.php has been > done. > I have sent an email with the body : > > > To see : > > <mailto:sympa@xxxxxxxxxxxxxxxxxxx?subject=TEST%20bac3.fsa> This is not correct mailto: HTML syntax. It should read: <a href="mailto:sympa@xxxxxxxxxxxxxxxxxxx?subject=TEST%20bac3.fsa">.....</a> > In squirrelmail, I get > > <pre> > > > To see : > <mailto:<a href="/1.4.12/src/compose.php?send_to=sympa > %40listes.uclouvain.be">sympa@xxxxxxxxxxxxxxxxxxx</a>?subject=TEST > %20bac3.fsa> Seems correct given what you gave it. Also note that I am going to recant on what I said earlier about not being able to use the plain text view to have active mailto: links. I just fixed 1.4.12svn to do so. Here is the patch: Index: functions/url_parser.php =================================================================== --- functions/url_parser.php (revision 12790) +++ functions/url_parser.php (working copy) @@ -76,6 +76,7 @@ 'https://', 'ftp://', 'telnet:', // Special case -- doesn't need the slashes + 'mailto:', // Special case -- doesn't use the slashes 'gopher://', 'news://'); @@ -85,12 +86,18 @@ ']', '[', '{', '}', "\240", ', ', '. ', ",\n", ",\r"); +/** + * Parses a body and converts all found URLs to clickable links. + * + * @param string body the body to process, by ref + * @return void + */ function parseUrl (&$body) { global $url_parser_poss_ends, $url_parser_url_tokens; $start = 0; $blength = strlen($body); - while ($start != $blength) { + while ($start < $blength) { $target_token = ''; $target_pos = $blength; @@ -112,6 +119,36 @@ $target_pos = strlen($check_str) + $start; } + // rfc 2368 (mailto URL) + if ($target_token == 'mailto:') { + $target_pos += 7; //skip mailto: + $end = $blength; + + $mailto = substr($body, $target_pos, $end-$target_pos); + + global $MailTo_PReg_Match; + if ((preg_match($MailTo_PReg_Match, $mailto, $regs)) && ($regs[0] != '')) { + //sm_print_r($regs); + $mailto_before = $target_token . $regs[0]; + $mailto_params = $regs[10]; + if ($regs[1]) { //if there is an email addr before '?', we need to merge it with the params + $to = 'to=' . $regs[1]; + 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', '/(?<!b)cc=/i', '/bcc=/i'), array('send_to=', 'send_to_cc=', 'send_to_bcc='), $mailto_params); + $comp_uri = makeComposeLink('src/compose.php' . $url_str, $mailto_before); + replaceBlock($body, $comp_uri, $target_pos - 7, $target_pos + strlen($regs[0])); + $target_pos += strlen($comp_uri) - 7; + } + } + else /* If there was a token to replace, replace it */ if ($target_token != '') { /* Find the end of the URL */ ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ ----- squirrelmail-users mailing list Posting guidelines: http://squirrelmail.org/postingguidelines List address: squirrelmail-users@xxxxxxxxxxxxxxxxxxxxx List archives: http://news.gmane.org/gmane.mail.squirrelmail.user List info (subscribe/unsubscribe/change options): https://lists.sourceforge.net/lists/listinfo/squirrelmail-users