I just downloaded a fresh HEAD and a fresh copy of the links module, enabled the links, links_related, and links_weblink modules, and added a weblink node.

When I try and click "Visit [sitename]" the URL becomes: ?q=?q=links/goto/1/1 and thus gives me a "Page not found" error. This makes this module unusable without Clean URLs. :(

CommentFileSizeAuthor
#2 links.inc.patch792 byteswebchick

Comments

webchick’s picture

Looks like the double-escape happens in links_get_list:

Line 878:
$url = links_format_goto_url($node->nid, $link['lid']);

(links_format_goto_url returns url('links/goto/'.$nid.'/'.$lid))

Line 906:
$list[] = links_l($linktext, $url, $attr);

links_l returns l($text, $url, $attribs);

So the link is first being sent through url() and then through l(), resulting in ?q=?q=....

webchick’s picture

Status: Active » Needs review
StatusFileSize
new792 bytes

Ok, here is "a" patch to solve this problem, which is cheesy and just removes the url() calls in links_format_goto_url. I assume those are there for a reason, however, so I have my doubts that this is the desired solution.

Bèr Kessels’s picture

Status: Needs review » Needs work

/**
* Make a Drupal-standard URL that points to the proper
* "goto" page in this module. The returned URL has already
* been processed through Drupal's url() function.
*/

So, in other words, if a module passes a link that already is url()ed, the bug is in that module. A patch for the offending module would be much nicer, IMO.

webchick’s picture

Sorry, Bèr, I didn't quite understand. There is no other offending module here, this all happens from within links.inc.

If we expect links_format_goto_url to return url()ed content, then we should not l() that content down in links_l() when the list is created, because then it wraps the thing in ?q= again. Or, we should not url() the links before they're passed to links_l() (this is the solution I proposed).

Or, do you mean that Drupal's l() and url() functions should be smart enough to know if a link is already in the ?q= format and not prepend ?q= again if that's the case?

Steve Dondley’s picture

webchick, replace "module" with "function" and you'll see what he means. The problem is the call to the function, not the function itself.

syscrusher’s picture

Assigned: Unassigned » syscrusher

Oops...looks like I goofed. I'm at work right now, but will take a look at this problem this evening and hopefully get a CVS change committed after I have time to review your comments more carefully. For now, I just wanted to let you know I've seen the bug report. Thanks for finding this!

Scott

syscrusher’s picture

Status: Needs work » Fixed

This is fixed in today's CVS commit. The problem was a design flaw in the semantics of links_format_goto_url(), which has now been redefined to return the Drupal URL rather than the physical URL. (In other words, "working as designed -- designed wrong!")

Thanks for a very helpful bug report and discussion.

Syscrusher

Anonymous’s picture

Status: Fixed » Closed (fixed)