As per RFC 3986 URI schemes are: ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ).
authorJan Schneider <jan@horde.org>
Thu, 20 Jan 2011 09:57:16 +0000 (10:57 +0100)
committerJan Schneider <jan@horde.org>
Thu, 20 Jan 2011 09:57:16 +0000 (10:57 +0100)
framework/Core/lib/Horde.php
framework/Text_Filter/lib/Horde/Text/Filter/Linkurls.php
wicked/lib/Wicked.php

index 4774a84..5012fd4 100644 (file)
@@ -922,9 +922,10 @@ HTML;
 
         $puri = parse_url($uri);
         $url = '';
+        $schemeRegexp = '|^([a-zA-Z][a-zA-Z0-9+.-]{0,19})://|';
         $webroot = ltrim($GLOBALS['registry']->get('webroot', empty($opts['app']) ? null : $opts['app']), '/');
 
-        if ($full && !isset($puri['scheme']) && !preg_match('|^([a-zA-Z0-9][\w+-]{0,19})://|', $webroot) ) {
+        if ($full && !isset($puri['scheme']) && !preg_match($schemeRegexp, $webroot) ) {
             /* Store connection parameters in local variables. */
             $server_name = $GLOBALS['conf']['server']['name'];
             $server_port = $GLOBALS['conf']['server']['port'];
@@ -961,9 +962,9 @@ HTML;
             $url = $puri['scheme'] . '://' . $puri['host'];
         }
 
-        if (isset($puri['path']) && substr($puri['path'], 0, 1) == '/' && !preg_match('|^([a-zA-Z0-9][\w+-]{0,19})://|', $webroot)) {
+        if (isset($puri['path']) && substr($puri['path'], 0, 1) == '/' && !preg_match($schemeRegexp, $webroot)) {
             $url .= $puri['path'];
-        } elseif (isset($puri['path']) && preg_match('|^([a-zA-Z0-9][\w+-]{0,19})://|', $webroot)) {
+        } elseif (isset($puri['path']) && preg_match($schemeRegexp, $webroot)) {
             $url = $webroot . (substr($puri['path'], 0, 1) != '/' ? '/' : '') . $puri['path'];
         } else {
             $url .= '/' . ($webroot ? $webroot . '/' : '') . (isset($puri['path']) ? $puri['path'] : '');
index 02b9a5b..1b2738f 100644 (file)
@@ -83,7 +83,7 @@ class Horde_Text_Filter_Linkurls extends Horde_Text_Filter_Base
 
         return array(
             'regexp' => array(
-                '|([a-zA-Z0-9][\w+-]{0,19})://([^\s"<]*[\w+#?/&=])|e' => $replacement
+                '|^([a-zA-Z][a-zA-Z0-9+.-]{0,19})://([^\s"<]*[\w+#?/&=])|e' => $replacement
             )
         );
     }
index b07f180..f67096e 100644 (file)
@@ -82,7 +82,7 @@ class Wicked
         }
 
         $url = Horde::url($script, $full, array('append_session' => $append_session));
-        $url->url = preg_replace('|^[a-zA-Z0-9][\w+-]{0,19}://[^/]*|', '', $url->url);
+        $url->url = preg_replace('|^([a-zA-Z][a-zA-Z0-9+.-]{0,19})://[^/]*|', '', $url->url);
 
         return $url;
     }