Index: cck_redirection.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cck_redirection/cck_redirection.module,v
retrieving revision 1.1.4.2
diff -u -p -w -r1.1.4.2 cck_redirection.module
--- cck_redirection.module	31 Oct 2008 21:51:55 -0000	1.1.4.2
+++ cck_redirection.module	30 Oct 2010 22:07:19 -0000
@@ -567,7 +567,9 @@ function _cck_redirection_redirect(&$ele
 
     if (user_access('bypass redirection')) {
       if (!empty($element['#item']['value'])) {
-        drupal_set_message(t('This node is redirected to a !r.', array('!r' => l(t('remote URI'), $element['#item']['value']))));
+        $url = _cck_redirection_parse_url($element['#item']['value']);
+        $options = array('query' => $url['query'], 'fragment' => $url['fragment']);
+        drupal_set_message(t('This node is redirected to a !r.', array('!r' => l(t('remote URI'), $url['url'], $options))));
       }
     } else {
       switch ($widget['redirect_type']) {
@@ -595,7 +597,8 @@ function _cck_redirection_redirect(&$ele
  */
 function _cck_redirection_divert($element) {
   if (!empty($element['#item']['value'])) {
-    drupal_goto($element['#item']['value']);
+    $url = _cck_redirection_parse_url($element['#item']['value']);
+    drupal_goto($url['url'], $url['query'], $url['fragment']);
   }
 }
 
@@ -618,3 +621,54 @@ function _cck_redirection_frameset($elem
     drupal_goto('redirect', 'uri=' . drupal_urlencode($element['#item']['value']));
   }
 }
+
+/**
+ * Helper function for decoding and then re-encoding URLs. Useful for separating
+ * out the query and fragment from a URL.
+ */
+function _cck_redirection_parse_url($element) {
+  $url = parse_url($element);
+
+  if (!isset($url['query'])) { $url['query'] = NULL; }
+  if (!isset($url['fragment'])) { $url['fragment'] = NULL; }
+
+  $full_url = NULL;
+  $url_parts = array('scheme', 'user', 'host', 'port', 'path');
+
+  foreach ($url_parts as $part) {
+    if (!empty($url[$part])) {
+      switch ($part) {
+        case 'scheme':
+          $full_url .= $url[$part].'://';
+        break;
+
+        case 'user':
+          $full_url .= $url[$part];
+          if (!empty($url['pass'])) {
+            $full_url .= ':'.$url['pass'];
+          }
+          $full_url .= '@';
+        break;
+
+        case 'port':
+          $full_url .= ':'.$url[$part];
+        break;
+
+        default:
+          $full_url .= $url[$part];
+        break;
+      }
+    }
+  }
+
+  if (parse_url($full_url) !== FALSE) {
+    return array(
+      'url' => $full_url,
+      'query' => $url['query'],
+      'fragment' => $url['fragment']
+    );
+
+  } else {
+    return FALSE;
+  }
+}
