? valid_url_6.patch
Index: common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.572
diff -u -F^f -r1.572 common.inc
--- common.inc	1 Sep 2006 08:44:25 -0000	1.572
+++ common.inc	5 Sep 2006 11:21:43 -0000
@@ -694,11 +694,12 @@ function valid_email_address($mail) {
  *   TRUE if the URL is in a valid format.
  */
 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($path, ':') !== FALSE && filter_xss_bad_protocol($path, FALSE) == check_plain($path);
   }
   else {
+    $allowed_characters = '[a-z0-9\/:_\-_\.\?\$,~=#&%\+]';
     return preg_match("/^". $allowed_characters ."+$/i", $url);
   }
 }
@@ -1024,8 +1025,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);
