--- path_redirect.module 2008-04-14 16:15:20.000000000 +0200 +++ path_redirect.new.module 2008-04-14 16:37:21.000000000 +0200 @@ -28,7 +28,7 @@ function path_redirect_init() { if (isset($_SERVER['QUERY_STRING'])) { $query = preg_replace('/^q=([^&]*).*$/', '\1', $_SERVER['QUERY_STRING']); } - $r = db_fetch_object(db_query("SELECT redirect, query, fragment, type FROM {path_redirect} WHERE path = '%s' OR path = '%s'", $query, utf8_encode($query))); + $r = db_fetch_object(db_query("SELECT redirect, query, fragment, type FROM {path_redirect} WHERE path = '%s' OR path = '%s'", $query, urlencode(utf8_encode($query)))); if ($r) { if (function_exists('drupal_goto')) { // if there's a result found, do the redirect @@ -144,7 +144,7 @@ function path_redirect_admin($rid = FALS $query = $r->query ? "?$r->query" : ''; $fragment = $r->fragment ? "#$r->fragment" : ''; $rows[] = array( - $path, + urldecode($path), check_url($redirect . $query . $fragment), $types[$r->type]['title'], array('data' => l(t('test'), $r->path, array())), @@ -250,7 +250,11 @@ function path_redirect_edit($edit = arra return $form; } -function path_redirect_edit_validate($form_id, &$form_values) { +function path_redirect_edit_validate($form_id, &$form_values, $form) { + // Allow spaces in "from" path + $form_values['path'] = urlencode($form_values['path']); + form_set_value($form['path'], $form_values['path']); + if (trim($form_values['path']) == '') { form_set_error('path', t('You must enter a from path.')); } @@ -292,9 +296,6 @@ function path_redirect_edit_validate($fo if ($form_values['path'] === $form_values['redirect']) { form_set_error('redirect', t('You are attempting to redirect the page to itself. This will result in an infinite loop.')); } - - // Allow spaces in "from" path - $form_values['path'] = str_replace("+", " ", $form_values['path']); } function path_redirect_edit_submit($form_id, &$form_values) { @@ -327,6 +328,10 @@ function path_redirect_load($rid = NULL, } else if (!empty($from)) { $result = db_fetch_array(db_query("SELECT rid, path, redirect, query, fragment, type FROM {path_redirect} WHERE path = '%s'", $from)); } + + if ($result) { + $result['path'] = urldecode($result['path']); + } return $result; }