Re: Patch for mailto: link urlencoding
"Michael A. Puls II" <[email protected]>
| Newsgroups | gmane.mail.squirrelmail.devel |
|---|---|
| Message-ID | <op.u6nfy6im1ejg13@sandra-svwliu01> |
On Wed, 13 Jan 2010 12:25:03 -0500, Michael A. Puls II <[email protected]> wrote: > On Wed, 13 Jan 2010 10:33:44 -0500, Michael A. Puls II > <[email protected]> wrote: >> Attached is the full patch. Hope that helps. > > Attaching the same patch but using str_replace() since regex isn't > needed. Attaching new patch that adds a comment as to why replacing + with %2B is needed. Including a patch for both 1.4.x and 1.5.x for good measure, although 1.4.x and 1.5.x seem to be using the same version of url_parser.php. Paul, are you willing to accept this patch? Or, do you require changes? -- Michael ------------------------------------------------------------------------------ Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev ----- squirrelmail-devel mailing list Posting guidelines: http://squirrelmail.org/postingguidelines List address: [email protected] List archives: http://news.gmane.org/gmane.mail.squirrelmail.devel List info (subscribe/unsubscribe/change options): https://lists.sourceforge.net/lists/listinfo/squirrelmail-devel
sm1.4.x-url_parser.php.patch
(application/octet-stream, 1.3 KB)
Index: functions/url_parser.php
===================================================================
--- functions/url_parser.php (revision 13883)
+++ functions/url_parser.php (working copy)
@@ -130,9 +130,15 @@
if ((preg_match($MailTo_PReg_Match, $mailto, $regs)) && ($regs[0] != '')) {
//sm_print_r($regs);
$mailto_before = $target_token . $regs[0];
- $mailto_params = $regs[10];
+ /**
+ * '+' characters in a mailto URI don't need to be percent-encoded.
+ * However, when mailto URI data is transported via HTTP, '+' must
+ * be percent-encoded as %2B so that when the HTTP data is
+ * percent-decoded, you get '+' back and not a space.
+ */
+ $mailto_params = str_replace("+", "%2B", $regs[10]);
if ($regs[1]) { //if there is an email addr before '?', we need to merge it with the params
- $to = 'to=' . $regs[1];
+ $to = 'to=' . str_replace("+", "%2B", $regs[1]);
if (strpos($mailto_params, 'to=') > -1) //already a 'to='
$mailto_params = str_replace('to=', $to . '%2C%20', $mailto_params);
else {
sm1.5.x-url_parser.php.patch
(application/octet-stream, 1.3 KB)
Index: functions/url_parser.php
===================================================================
--- functions/url_parser.php (revision 13883)
+++ functions/url_parser.php (working copy)
@@ -146,9 +146,15 @@
if ((preg_match($MailTo_PReg_Match, $mailto, $regs)) && ($regs[0] != '')) {
//sm_print_r($regs);
$mailto_before = $target_token . $regs[0];
- $mailto_params = $regs[10];
+ /**
+ * '+' characters in a mailto URI don't need to be percent-encoded.
+ * However, when mailto URI data is transported via HTTP, '+' must
+ * be percent-encoded as %2B so that when the HTTP data is
+ * percent-decoded, you get '+' back and not a space.
+ */
+ $mailto_params = str_replace("+", "%2B", $regs[10]);
if ($regs[1]) { //if there is an email addr before '?', we need to merge it with the params
- $to = 'to=' . $regs[1];
+ $to = 'to=' . str_replace("+", "%2B", $regs[1]);
if (strpos($mailto_params, 'to=') > -1) //already a 'to='
$mailto_params = str_replace('to=', $to . '%2C%20', $mailto_params);
else {