From 8f94b1aad656ec19c92b7ec7aa7f9e4cd4ac60a0 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Tue, 05 Oct 2010 06:17:12 -0400
Subject: [PATCH] - Convert to lowercase only domain part of email address on login
---
program/include/rcube_string_replacer.php | 23 ++++++++++++++---------
1 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/program/include/rcube_string_replacer.php b/program/include/rcube_string_replacer.php
index 064a723..0471dd0 100644
--- a/program/include/rcube_string_replacer.php
+++ b/program/include/rcube_string_replacer.php
@@ -4,8 +4,8 @@
+-----------------------------------------------------------------------+
| program/include/rcube_string_replacer.php |
| |
- | This file is part of the RoundCube Webmail client |
- | Copyright (C) 2009, RoundCube Dev. - Switzerland |
+ | This file is part of the Roundcube Webmail client |
+ | Copyright (C) 2009, Roundcube Dev. - Switzerland |
| Licensed under the GNU GPL |
| |
| PURPOSE: |
@@ -15,7 +15,7 @@
| Author: Thomas Bruederli <roundcube@gmail.com> |
+-----------------------------------------------------------------------+
- $Id: $
+ $Id$
*/
@@ -35,11 +35,15 @@
function __construct()
{
- $url_chars = 'a-z0-9_\-\+\*\$\/&%=@#:;';
- $url_chars_within = '\?\.~,!';
+ // Simplified domain expression for UTF8 characters handling
+ $utf_domain = '[^&@"\'\\/\s\r\t\n]+\\.[a-z]{2,5}';
- $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->link_pattern = "/([\w]+:\/\/|\Wwww\.)($utf_domain(\S+)?)/i";
+ $this->mailto_pattern = "/("
+ ."[-\w!\#\$%&\'*+~\/^`|{}=]+(?:\.[-\w!\#\$%&\'*+~\/^`|{}=]+)*" // local-part
+ ."@$utf_domain" // domain-part
+ ."(\?\S+)?" // e.g. ?subject=test...
+ .")/i";
}
/**
@@ -74,7 +78,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 +87,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