From 618cb0d8dde52c2c8a181334e7a3c33fbc26c236 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Fri, 10 Sep 2010 09:22:54 -0400
Subject: [PATCH] - Don't trim spaces from the end of line when converting to format=flowed
---
program/include/rcube_string_replacer.php | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/program/include/rcube_string_replacer.php b/program/include/rcube_string_replacer.php
index 064a723..0568cc0 100644
--- a/program/include/rcube_string_replacer.php
+++ b/program/include/rcube_string_replacer.php
@@ -15,7 +15,7 @@
| Author: Thomas Bruederli <roundcube@gmail.com> |
+-----------------------------------------------------------------------+
- $Id: $
+ $Id$
*/
@@ -39,7 +39,10 @@
$url_chars_within = '\?\.~,!';
$this->link_pattern = "/([\w]+:\/\/|\Wwww\.)([a-z0-9\-\.]+[a-z]{2,4}([$url_chars$url_chars_within]*[$url_chars])?)/i";
- $this->mailto_pattern = "/([a-z0-9][a-z0-9\-\.\+\_]*@[a-z0-9]([a-z0-9\-][.]?)*[a-z0-9]\\.[a-z]{2,5})/i";
+ $this->mailto_pattern = "/("
+ ."[-\w!\#\$%&\'*+~\/^`|{}=]+(?:\.[-\w!\#\$%&\'*+~\/^`|{}=]+)*" // local-part
+ ."@([a-z0-9]([-a-z0-9]*[a-z0-9])?\\.)+[a-z]{2,5}" // domain-part
+ .")/i";
}
/**
@@ -74,7 +77,7 @@
$i = -1;
$scheme = strtolower($matches[1]);
- if ($scheme == 'http://' || $scheme == 'https://' || $scheme == 'ftp://') {
+ if (preg_match('!^(http|ftp|file)s?://!', $scheme)) {
$url = $matches[1] . $matches[2];
$i = $this->add(html::a(array('href' => $url, 'target' => '_blank'), Q($url)));
}
@@ -83,7 +86,8 @@
$i = $this->add($m[1] . html::a(array('href' => 'http://' . $url, 'target' => '_blank'), Q($url)));
}
- return $i >= 0 ? $this->get_replacement($i) : '';
+ // Return valid link for recognized schemes, otherwise, return the unmodified string for unrecognized schemes.
+ return $i >= 0 ? $this->get_replacement($i) : $matches[0];
}
/**
--
Gitblit v1.9.1