Index: me.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/me/me.module,v
retrieving revision 1.5.2.7.2.8
diff -u -p -r1.5.2.7.2.8 me.module
--- me.module   1 Jul 2009 22:59:11 -0000       1.5.2.7.2.8
+++ me.module   5 Jul 2009 22:40:46 -0000
@@ -188,32 +188,31 @@ function me_handler($parts, $callback) {
   array_shift($args);
   array_shift($args);

-  // If we want the uid shown in the address bar, we need to do a redirect.
-  if (me_variable_get('me_redirect') || _me_user_disabled() || !_me_handle_path($_GET['q'])) {
-    $redirect = FALSE;
-    // Get the menu path arguments.
-    $menu_parts = explode('/', $_GET['q'], MENU_MAX_PARTS);
-
-    // Loop over each part. If it's a %me wildcard, then
-    // check the corresponding menu part for the me alias,
-    // if so, replace it out with the user id so we can redirect correctly.
-    // If no changes are required, then call the required function.
-    while (list($key, $val) = each($parts)) {
-      if (0 === strpos($val, '%me') && _me_is_alias($menu_parts[$key])) {
-        $redirect = TRUE;
-        $menu_parts[$key] = $GLOBALS['user']->uid;
-      }
+  // We need to get a correct path no matter what so we can reset $_GET['q'];
+  $redirect = FALSE;
+  // Get the menu path arguments.
+  $menu_parts = explode('/', $_GET['q'], MENU_MAX_PARTS);
+
+  // Loop over each part. If it's a %me wildcard, then
+  // check the corresponding menu part for the me alias,
+  // if so, replace it out with the user id so we can redirect correctly.
+  // If no changes are required, then call the required function.
+  while (list($key, $val) = each($parts)) {
+    if (0 === strpos($val, '%me') && _me_is_alias($menu_parts[$key])) {
+      $redirect = TRUE;
+      $menu_parts[$key] = $GLOBALS['user']->uid;
     }
+  }
+  $path = implode('/', $menu_parts);

-    if ($redirect) {
-      $path = implode('/', $menu_parts);
-      // Save on an extra redirect by also checking the anonymous redirect here.
-      $redirect_path = me_variable_get('me_redirect_anonymous');
-      if ($GLOBALS['user']->uid == 0 && !empty($redirect_path)) {
-        $path = $redirect_path;
-      }
-      drupal_goto($path);
+  // If we want the uid shown in the address bar, we need to do a redirect.
+  if ((me_variable_get('me_redirect') || _me_user_disabled() || !_me_handle_path($_GET['q'])) && $redirect) {
+    // Save on an extra redirect by also checking the anonymous redirect here.
+    $redirect_path = me_variable_get('me_redirect_anonymous');
+    if ($GLOBALS['user']->uid == 0 && !empty($redirect_path)) {
+      $path = $redirect_path;
     }
+    drupal_goto($path);
   }

   // Before going any further, set the current menu router item to include
@@ -226,6 +225,7 @@ function me_handler($parts, $callback) {
       $router_item['load_functions'][$index] = 'user_load';
     }
   }
+  $_GET['q'] = $path;
   menu_set_item($_GET['q'], $router_item);

   return call_user_func_array($callback, $args);
   