--- common.inc	2008-01-22 04:36:49.000000000 -0500
+++ common.inc	2008-03-21 10:30:41.000000000 -0400
@@ -1186,11 +1186,25 @@ function url($path = NULL, $query = NULL
     $clean_url = (bool)variable_get('clean_url', '0');
   }
 
-  $base = ($absolute ? $base_url . '/' : base_path());
+  // Preserve the original path before aliasing.
+  $original_path = $path;
 
   // The special path '<front>' links to the default front page.
-  if (!empty($path) && $path != '<front>') {
+  if ($path == '<front>') {
+    $path = '';
+  }
+  elseif (!empty($path)) {
     $path = drupal_get_path_alias($path);
+  }
+
+  if (function_exists('custom_url_rewrite_outbound')) {
+    // Modules may alter outbound links by reference.
+    custom_url_rewrite_outbound($path, $query, $fragment, $absolute, $base_url, $original_path);
+  }
+
+  $base = ($absolute ? $base_url . '/' : base_path());
+
+  if (!empty($path)) {
     $path = drupal_urlencode($path);
     if (!$clean_url) {
       if (isset($query)) {
