Entering "calendar?tid=22" results in a redirection only to "calendar". This also happens with external links. We're using Field Redirection with the Link module on Drupal 7.9.

Comments

karlshea’s picture

Status: Active » Needs review
StatusFileSize
new521 bytes

I think this should fix it, can someone else check this out?

damienmckenna’s picture

Status: Needs review » Reviewed & tested by the community

Looks good, thanks!

damienmckenna’s picture

BTW I changed it to use drupal_http_build_query.

damienmckenna’s picture

Status: Reviewed & tested by the community » Fixed

This has been committed and included in the new v7.x-2.3 release.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

codewatson’s picture

Title: Query strings get stripped off of URLs » Correct handling of Query strings and fragments(anchors)
Version: 7.x-2.2 » 7.x-2.3
Status: Closed (fixed) » Active

This is not quite right, if you are using drupal_goto(), you cannot pass a query string or fragment (anchor) directly in the path, drupal_goto will try to encode ?, =, and # which will break urls with them in it. You have to pass those elements as an array as the second parameter, right now you are passing an empty array. I've also updated the link_field case to try to match an internal system path to its alias if it is one. See below:

  // Work out the destination path to redirect to. Each field type is handled
  // slightly differently, so identify that here.
  $path = '';
  $options = array();
  if (!empty($field['type'])) {
    switch ($field['type']) {
      // Link field.
      case 'link_field':
        if (!empty($item['url'])) {
          $alias = drupal_get_path_alias($item['url']);
          $options = array('query' => $item['query'], 'fragment' => $item['fragment']);
          if ($alias != $item['url']) {
            $path = $alias;
          } else {
            $path = $item['url'];
          }
        }
        break;

Correct the message display, pass $options as the second parameter to url():

      $message = t('This page is set to redirect to <a href="!path">another URL</a>, but you have permission to see the page and not be automatically redirected.', array('!path' => url($path, $options)));

Pass $options as the second parameter in drupal_goto():

      drupal_goto($path, $options, $response_code);

Probably not the most elegant solution to this, especially when it comes to determining if a path is an internal system path with an alias, but it gets the job done in my limited testing.

damienmckenna’s picture

Status: Active » Needs review
StatusFileSize
new2.05 KB

@dwatson: Thanks for identifying that fragments were also being truncated (I'd have preferred a new issue but it's not a big deal). I'm going to go with what I've attached.

Status: Needs review » Needs work

The last submitted patch, field_redirection-n1331832-7.patch, failed testing.

damienmckenna’s picture

Status: Needs work » Fixed

Committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.