--- path_redirect.module 2008-01-19 13:51:06.000000000 -0600
+++ path_redirect.module 2008-01-20 17:30:47.000000000 -0600
@@ -28,11 +28,11 @@ 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 = trim($_SERVER['REQUEST_URI'], '/');
+ 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'", $query, utf8_encode($query)));
+ $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) {
if (function_exists('drupal_goto')) {
// if there's a result found, do the redirect
@@ -151,7 +151,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(), preg_replace('/.*\?/', '', $r->path))),
array('data' => l(t('edit'), 'admin/build/path_redirect/edit/'. $r->rid)),
array('data' => l(t('delete'), 'admin/build/path_redirect/edit/'. $r->rid .'/delete')),
);
@@ -270,10 +270,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 from path.');
- }
// Make sure "from" has the form of a local Drupal path
if (!valid_url($form_values['path'])) {
$path_error .= ' '. t('The redirect from path does not appear valid. This must be a local Drupal path.');