Index: drupal/includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.572
diff -u -F^f -r1.572 common.inc
--- drupal/includes/common.inc	1 Sep 2006 08:44:25 -0000	1.572
+++ drupal/includes/common.inc	5 Sep 2006 09:24:10 -0000
@@ -696,9 +696,11 @@ function valid_email_address($mail) {
 function valid_url($url, $absolute = FALSE) {
   $allowed_characters = '[a-z0-9\/:_\-_\.\?\$,~=#&%\+]';
   if ($absolute) {
-    return preg_match("/^(http|https|ftp):\/\/". $allowed_characters ."+$/i", $url);
+    // Only call the slow filter_xss_bad_protocol if $path contains a ':'.
+    return strpos($url, ':') !== FALSE && filter_xss_bad_protocol($url, FALSE) == check_plain($url);
   }
   else {
+    $allowed_characters = '[a-z0-9\/:_\-_\.\?\$,~=#&%\+]';
     return preg_match("/^". $allowed_characters ."+$/i", $url);
   }
 }
@@ -1024,8 +1026,7 @@ function url($path = NULL, $query = NULL
   }
 
   // Return an external link if $path contains an allowed absolute URL.
-  // Only call the slow filter_xss_bad_protocol if $path contains a ':'.
-  if (strpos($path, ':') !== FALSE && filter_xss_bad_protocol($path, FALSE) == check_plain($path)) {
+  if (valid_url($path, TRUE)) {
     // Split off the fragment
     if (strpos($path, '#')) {
       list($path, $old_fragment) = explode('#', $path, 2);
