On our drupal installation, we have some external code we wanted to link to in the menu, which had query in the url. The url() method urlencodes the menu urls including the query string. So, I tried to do an absolute url by using a url as following in the menu:

/path/to/script?query=ourstuff

And not only did it continue to urlencode it, but it prepended an extra slash at the beginning, which produces a completely invalid link (Firefox, at least, tries to link to http://path/to/script).

The attached patch simply checks for a begining slash on a url, and if it finds it, treats it just like a http:// url. This behavior seems more expected rather than creating a compeletly broken url.

The patch is against the latest cvs HEAD.

CommentFileSizeAuthor
absoluteurl.patch924 bytesSqueeself

Comments

beginner’s picture

Category: bug » support

Why can't you put in an absolute (external) URL with the http://www.example.com/ bit in the path field? It seems to work.

Just create the menu item which links to:
http://www.example.com/path/to/script?query=ourstuff

Squeeself’s picture

Unfortunately, that means that it can only be used with a single hostname. This makes it much more generic, which is especially helpful when we have a test site that is a duplicate of the main site.

Squeeself’s picture

Also, as stated, it is very unexpected behavior to have the query elements urlencoded on a url input field. A user will expect to be able to have a normal url used without breaking. It either needs to be made clear that is what happens, or needs to be changed so it doesn't happen, as this patch does.

coreb’s picture

Version: x.y.z » 5.x-dev
Status: Needs review » Patch (to be ported)

Moving out of the "x.y.z" queue to a real queue.

Steven’s picture

Status: Patch (to be ported) » Closed (won't fix)

This is by design. The field description says to enter a Drupal menu path, or an absolute URL. "/foo/bar" is still a relative URL.

liquidcms’s picture

Heine suggested that my issue (http://drupal.org/node/101558) might be related.

I don't think it is quite the same issue; but pretty sure there is a bug in common.inc

peter...