[prev in list] [next in list] [prev in thread] [next in thread]
List: squirrelmail-cvs
Subject: [SM-CVS] SF.net SVN: squirrelmail: [12790]
From: pdontthink () users ! sourceforge ! net
Date: 2007-11-27 11:58:35
Message-ID: E1Iwz5H-0004Kw-N6 () sc8-pr-svn2 ! sourceforge ! net
[Download RAW message or body]
Revision: 12790
http://squirrelmail.svn.sourceforge.net/squirrelmail/?rev=12790&view=rev
Author: pdontthink
Date: 2007-11-27 03:58:35 -0800 (Tue, 27 Nov 2007)
Log Message:
-----------
Backport ability to take mailto: links (convert into SM compose links) in magicHTML() \
from DEVEL
Modified Paths:
--------------
branches/SM-1_4-STABLE/squirrelmail/functions/mime.php
branches/SM-1_4-STABLE/squirrelmail/functions/url_parser.php
Modified: branches/SM-1_4-STABLE/squirrelmail/functions/mime.php
===================================================================
--- branches/SM-1_4-STABLE/squirrelmail/functions/mime.php 2007-11-27 11:22:32 UTC \
(rev 12789)
+++ branches/SM-1_4-STABLE/squirrelmail/functions/mime.php 2007-11-27 11:58:35 UTC \
(rev 12790) @@ -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;
}
Modified: branches/SM-1_4-STABLE/squirrelmail/functions/url_parser.php
===================================================================
--- branches/SM-1_4-STABLE/squirrelmail/functions/url_parser.php 2007-11-27 11:22:32 \
UTC (rev 12789)
+++ branches/SM-1_4-STABLE/squirrelmail/functions/url_parser.php 2007-11-27 11:58:35 \
UTC (rev 12790) @@ -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;
@@ -196,4 +205,4 @@
}
return $ret;
}
-?>
\ No newline at end of file
+?>
This was sent by the SourceForge.net collaborative development platform, the world's \
largest Open Source development site.
-------------------------------------------------------------------------
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-cvs mailing list
List address: squirrelmail-cvs@lists.sourceforge.net
List info (subscribe/unsubscribe/change options): \
https://lists.sourceforge.net/lists/listinfo/squirrelmail-cvs
Repository: http://squirrelmail.org/svn
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic