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.
| Comment | File | Size | Author |
|---|---|---|---|
| absoluteurl.patch | 924 bytes | Squeeself |
Comments
Comment #1
beginner commentedWhy 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
Comment #2
Squeeself commentedUnfortunately, 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.
Comment #3
Squeeself commentedAlso, 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.
Comment #4
coreb commentedMoving out of the "x.y.z" queue to a real queue.
Comment #5
Steven commentedThis is by design. The field description says to enter a Drupal menu path, or an absolute URL. "/foo/bar" is still a relative URL.
Comment #6
liquidcms commentedHeine 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...