--- a/path_redirect.module	2009-06-27 23:57:20.000000000 +0200
+++ b/path_redirect.module	2009-10-11 02:48:00.000000000 +0200
@@ -161,12 +161,20 @@
   unset($query['q']); // Use array_diff or array_diff_assoc?
   if ($query) {
     $path = urldecode(request_uri());
+    if (!mb_check_encoding($path)) {
+      $path = mb_convert_encoding($path, "UTF-8", "ASCII");
+    }
     $path = drupal_substr($path, drupal_strlen(base_path()));
+    $orig_path = $path;
     // Remove ($language->language .'/') via preg_replace?
     $path = _path_redirect_split_path($path);
-    $where[] = "(path = '%s' OR path = '%s')";
+    $where[] = "(path = '%s' OR path = '%s' OR path = '%s')";
     $args[':path'] = $_GET['q'];
     $args[':path_query'] = $_GET['q'] .'?'. $path['query'];
+    $args[':query'] = $orig_path;
+    if (preg_match("/^\?.*/", $orig_path)) {
+	    echo (request_uri());
+    }
     $sort[] = 'path DESC';
     //$where[] = "(path_query = '%s' OR path_query = '')";
     //$args[':path_query'] = $path['query'];
@@ -182,7 +190,6 @@
   $where[] = "(language = '%s' OR language = '')";
   $args[':language'] = $language->language;
   $sort[] = 'language DESC';
-
   $r = path_redirect_load($where, $args, $sort);
 
   if ($r) {
@@ -263,7 +270,12 @@
 
   // Remove beginning and trailing slashes from path.
   // @todo Move to validation.
+  $edit['path'] = urldecode($edit['path']);
   $edit['path'] = preg_replace('/^\/|\/\?|\/$/', '', $edit['path']);
+  if (!mb_check_encoding($edit['path'])) {
+    $edit['path'] = mb_convert_encoding($edit['path'], "UTF-8", "ASCII");
+  }
+//  echo $edit['path'];
 
   if (empty($edit['rid'])) {
     return drupal_write_record('path_redirect', $edit);
@@ -290,6 +302,7 @@
 
   if ($where && $args) {
     $sql = "SELECT * FROM {path_redirect} WHERE ". implode(' AND ', $where);
+//print_r($args);
     if ($sort) {
       $sql .= ' ORDER BY '. implode(' ,', $sort);
     }
