Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.1283
diff -u -p -r1.1283 common.inc
--- includes/common.inc	3 Jan 2011 06:51:00 -0000	1.1283
+++ includes/common.inc	4 Jan 2011 05:19:09 -0000
@@ -2308,6 +2308,51 @@ function l($text, $path, array $options 
   );
 
   // Append active class.
+  // Compare the link to the current page's path, but don't modify $path or
+  // $options, as they are sent to url() below.
+
+  // If Clean URLs is enabled and there is an alias for the node, then $path
+  // is equal to $text. Test for that condition and set the working variable
+  // to the actual path.
+  $real_path = ($text == $path) ? drupal_get_normal_path($path) : $path;
+  $query = '';
+  $current_page = $_GET['q'];
+
+  // If the pathes are not the same, don't even bother doing anything else.
+  if ($real_path == $current_page) {
+    // Check to see if there is a query key in $options.
+    if (!empty($options['query'])) {
+      // Parse the $options['query'] array and reconstruct the query for
+      // testing.
+      foreach($options['query'] as $key => $value) {
+        $query .= $key . '=' . $value . '&';
+      }
+
+      // Complete the query and remove the final '&'.
+      if (variable_get('clean_url')) {
+        // With Clean URLs enabled.
+        $query = '?' . drupal_substr($query, 0, drupal_strlen($query) - 1);
+      }
+      else {
+        // With Clean URLs disabled.
+        $query = '?q=node&' . drupal_substr($query, 0, drupal_strlen($query) - 1);
+      }
+    }
+
+    // Check to see if the URL contains a query part.
+    if ($_SERVER['QUERY_STRING'] != '') {
+      // Sometimes, there is a query in $_SERVER['QUERY_STRING'] that is
+      // simply either the path or alias of the current page. We need to
+      // verify that in order to accurately test.
+      $raw_query = drupal_substr($_SERVER['QUERY_STRING'], 2, drupal_strlen($_SERVER['QUERY_STRING']) - 2);
+      if ($raw_query != drupal_get_path_alias($real_path) && $raw_query != $real_path) {
+        // Add the query part to our test variable. We need both parts for
+        // accurate and complete testing.
+        $current_page .= '?' . $_SERVER['QUERY_STRING'];
+      }
+    }
+  }
+
   if (($path == $_GET['q'] || ($path == '<front>' && drupal_is_front_page())) &&
       (empty($options['language']) || $options['language']->language == $language_url->language)) {
     $options['attributes']['class'][] = 'active';
