--- path_redirect.module	2008-01-21 16:42:44.000000000 -0600
+++ path_redirect.module	2008-01-21 18:14:23.000000000 -0600
@@ -1,5 +1,5 @@
 <?php
-//$Id: path_redirect.module,v 1.3.2.20 2008/01/21 22:42:44 horsepunchkid Exp $
+//$Id: path_redirect.module,v 1.3.2.19 2008/01/19 19:51:06 horsepunchkid Exp $
 
 if (module_exists('workflow_ng')) {
   include_once(drupal_get_path('module', 'path_redirect'). '/path_redirect_workflow.inc');
@@ -26,11 +26,15 @@ function path_redirect_help($section) {
  */
 function path_redirect_init() {
   // see if this page has a redirect path
-  $query = '';
-  if (isset($_SERVER['QUERY_STRING'])) {
-    $query = preg_replace('/^q=([^&]*).*$/', '\1', $_SERVER['QUERY_STRING']);
+  $path = substr($_SERVER['REQUEST_URI'], strlen(base_path()));
+  if (preg_match('/^\?q=/', $path)) {
+    $path = preg_replace(array('/^\?q=/', '/&/'), array('', '?'), $path, 1);
+  }
+  $r = db_fetch_object(db_query("SELECT redirect, query, fragment, type FROM {path_redirect} WHERE path = '%s' OR path = '%s'", $path, utf8_encode($path)));
+  if (!$r) {
+    $path = preg_replace('/\?.*/', '', $path);
+    $r = db_fetch_object(db_query("SELECT redirect, query, fragment, type FROM {path_redirect} WHERE path = '%s' OR path = '%s'", $path, utf8_encode($path)));
   }
-  $r = db_fetch_object(db_query("SELECT redirect, query, fragment, type FROM {path_redirect} WHERE path = '%s' OR path = '%s'", $query, utf8_encode($query)));
   if ($r) {
     if (function_exists('drupal_goto')) {
       // if there's a result found, do the redirect
@@ -125,7 +129,7 @@ function path_redirect_admin($rid = FALS
       $path,
       check_url($redirect . $query . $fragment),
       $types[$r->type]['title'],
-      array('data' => l(t('test'), $r->path, array())),
+      array('data' => l(t('test'), preg_replace('/\?.*/', '', $r->path), array(), strstr($r->path, '?') ? preg_replace('/.*\?/', '', $r->path) : NULL)),
       array('data' => l(t('edit'), 'admin/build/path-redirect/edit/'. $r->rid)),
       array('data' => l(t('delete'), 'admin/build/path-redirect/delete/'. $r->rid)),
     );
@@ -263,10 +267,6 @@ function path_redirect_edit_validate($fo
     if (strstr($form_values['path'], '#')) {
       $path_error .= ' '. t('You cannot redirect from a fragment anchor.');
     }
-    // No query string allowed in "from" (but see #174961)
-    if (strstr($form_values['path'], '?')) {
-      $path_error .= ' '. t('You cannot currently include a query in your redirect <strong>from</strong> path.');
-    }
     // Make sure "from" has the form of a local Drupal path
     if (!valid_url($form_values['path'])) {
       $path_error .= ' '. t('The redirect <strong>from</strong> path does not appear valid. This must be a local Drupal path.');
