From 7fcb56b5b62877f074a8f6760f69a11f9ff40566 Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Sun, 07 Nov 2010 07:44:54 -0500
Subject: [PATCH] Support skins with old template names

---
 program/include/rcube_string_replacer.php |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/program/include/rcube_string_replacer.php b/program/include/rcube_string_replacer.php
index b1c1fbb..e219f30 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,16 @@
 
   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}';
+    $url = '[a-z0-9%=#@+?.:;&\\/_~-]+';
 
-    $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($url)?)/i";
+    $this->mailto_pattern = "/("
+        ."[-\w!\#\$%&\'*+~\/^`|{}=]+(?:\.[-\w!\#\$%&\'*+~\/^`|{}=]+)*"  // local-part
+        ."@$utf_domain"                                                 // domain-part
+        ."(\?$url)?"                                                    // e.g. ?subject=test...
+        .")/i";
   }
 
   /**

--
Gitblit v1.9.1