It''d be useful to be able to redirect to a url with a fragment/query.

So far to get it working I changed

            $url = parse_url($element['#item']['value']);
            drupal_set_message(t('This node is redirected to a !r.', array('!r' => l(t('remote URI'), $url['path'], 
                array('query'=>$url['query'],'fragment'=>$url['fragment'])
                ))));
function _cck_redirection_divert($element) {
  if (!empty($element['#item']['value'])) {
     $url = parse_url($element['#item']['value']);
    drupal_goto($url['path'],$url['query'],$url['fragment']);
  }
}

Reading the other issues I understand this module has issues with line endings so didn't make a patch (or rather... lazy fox, lazy).

Not sure how'd this effect remote urls, only tested for insite urls and it worked fine for both the message and the redirect.

CommentFileSizeAuthor
#3 593376-2.patch2.64 KBjbylsma
#1 593376.patch1 KBjbylsma

Comments

jbylsma’s picture

StatusFileSize
new1 KB

It appears that the line ending problem referenced as a reason not to create a patch is still open over a year later. Mostly as a quick reference for myself, I've converted his edits to a patch.

robin monks’s picture

Status: Active » Needs work

This patch has been tested and breaks cck_redirection fields that reference external sites. If you can correct this patch to work correctly both on internal and external URLs I'll work to get it committed.

jbylsma’s picture

Status: Needs work » Needs review
StatusFileSize
new2.64 KB

I created a quick helper function that takes the URL apart with parse_url and then logically puts it back to together. Nothing too fancy, but it seems to be working for internal and external sites, as well as with queries and fragments. I did build in port, user, and password support, which I'd be surprised if anybody used, but you never know.

I made the patch based on 6.x-1.2; it also includes the (now all re-written) work from hefox's patch. I also deleted any Windows newlines in this patch file (I just saw that they were removed in dev, awesome!). I hope that doesn't hamper any progress in getting this committed.

robin monks’s picture

Status: Needs review » Needs work

In light of http://drupal.org/node/445894 this patch seems to duplicate some of the URL validation accomplished there; I'd prefer if we could reuse most of that logic.

/Robin