Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.501
diff -u -p -r1.501 common.inc
--- includes/common.inc	22 Dec 2005 22:58:12 -0000	1.501
+++ includes/common.inc	22 Dec 2005 23:24:44 -0000
@@ -933,10 +933,10 @@ function format_date($timestamp, $type =
  */
 
 /**
- * Generate an internal Drupal URL.
+ * Generate a URL.
  *
  * @param $path
- *   The Drupal path being linked to, such as "admin/node".
+ *   The Drupal path being linked to, such as "admin/node" or "http://drupal.org/".
  * @param $query
  *   A query string to append to the link.
  * @param $fragment
@@ -963,12 +963,24 @@ function url($path = NULL, $query = NULL
   }
 
   $path = drupal_get_path_alias($path);
-  $path = drupal_urlencode($path);
 
   if (isset($fragment)) {
     $fragment = '#'. $fragment;
   }
 
+  // Return an external link if $path contains an allowed absolute URL.
+  // Only call the slow filter_xss_bad_protocol if $path contains ':'.
+  if (strpos($path, ':') !== FALSE && filter_xss_bad_protocol($path) == $path) {
+    if (isset($query)) {
+      return $path .'?'. $query . $fragment;
+    }
+    else {
+      return $path . $fragment;
+    }
+  }
+
+  $path = drupal_urlencode($path);
+
   $base = ($absolute ? $base_url .'/' : '');
 
   if (variable_get('clean_url', '0') == '0') {
