Problem:
URLs (fully formed external absolute links) are being output (using formatter: URL, absolute) as internal relative links.

For Example:

  • http://www.external.com/food/pizza.php Is being saved into the database.
  • A view is outputting the link using formatter: URL, absolute
  • The URL being output by views (and by tokens) is only: /food/pizza.php
  • I can see in the database (using phpMyAdmin) that the full URL is being saved: http://www.external.com/food/pizza.php

It seems like the URL is being filtered, or put through eh Drupal url() function, without flagging it as an external URL. Anyone have a clue why the external URL is being converted to an internal URL ?

Comments

wOOge’s picture

Issue summary: View changes
wOOge’s picture

I've narrowed the issue down to the following code in:

  • Link Module Version: 7.x-1.x-dev (March 23rd)
  • link.module around line 472

It seems that the lines:

    $item['url'] = url($url_parts['url'],
      array(
        'query' => isset($url_parts['query']) ? $url_parts['query'] : NULL,
        'fragment' => isset($url_parts['fragment']) ? $url_parts['fragment'] : NULL,
        'absolute' => TRUE,
        'html' => TRUE,
      )
    );

Take an (external) URL as input $url_parts['url'], and output an internal URL (having stripped away any protocol or domain). I tried hard-coding 'external' => TRUE, to see if that fixed the issue, but it doesn't.

Is anyone able to point me in a better direction?

wOOge’s picture

Trying this code in a plain (drupal bootstrapped) php file :

  $url = "http://www.twitter.com?test=foo";
  $url_parts = _link_parse_url($url);

  if (!empty($url_parts['url'])) {
    $item['url'] = url($url_parts['url'],
      array(
        'query' => isset($url_parts['query']) ? $url_parts['query'] : NULL,
        'fragment' => isset($url_parts['fragment']) ? $url_parts['fragment'] : NULL,
        'absolute' => TRUE,
        'html' => TRUE,
      )
    );
  }
 print $item['url'];

Works as expected — and aside from hard coding the $url variable, it's a code for code copy.

So this routine works in general, but not in the link.module

wOOge’s picture

... ok getting closer, but now I'm really stumped:

Using http://www.twitter.com?test=faoo as my test URL, the url() function returns this:

http://www.twitter.com?test=faoo

Using http://www.twitter.com/test/?test=faoo as my test URL (note the addition of /test/, the url() function returns this:

/test/?test=faoo

So, clearly the url() function is confused somehow... is this a core bug? Anyone else seeing this problem?

Johannes De Boeck’s picture

Did you resolve this issue?

I am having the same problem.. an email url gets the root url (domain name) added to it in front. Other links work fine.

dqd’s picture

This sounds weird. Can you please provide more info? Drupal core version, subversion, and additional modules involved? You have mentioned a view, so have you already checked issues queues from views and D7 core on this?

dqd’s picture

Status: Active » Postponed (maintainer needs more info)
fredeee’s picture

have the issue as well.
appeared to occur after some upgrades.

have three content types (forms), 2 are producing the correct result and one is not.
all three are using panels for output.
drupal 7.28

still using v1.2 not 7.x-1.x-dev

also http://www.xxx.com opens to blank web page

fredeee’s picture

this is proving difficult to understand

on checking it appears that we upgraded this site in march with these modules
Entity API 7.x-1.3 7.x-1.4 (Release notes)
jQuery Update 7.x-2.3 7.x-2.4 (Release notes)
Panopoly Images 7.x-1.1 7.x-1.2 (Release notes)
Panopoly Magic 7.x-1.1 7.x-1.2 (Release notes)
Panopoly Theme 7.x-1.1 7.x-1.2 (Release notes)
Panopoly Widgets 7.x-1.1 7.x-1.2 (Release notes)
Panopoly WYSIWYG 7.x-1.1 7.x-1.2 (Release notes)
after such the unexpected change in link display occurred.

we reverted back after the problems.

we have upgraded a number of modules, inc those above again in june and the problem is there.
the problem is consistent across content types, however some content types do not have the problem as stated above.

have used - http://un.org in the link, with no title and with tile, and all works OK
using http;//un.org/en/events/.... it breaks and http://un.org is ignored when the link is selected for opening

will have a look at entity module as this has had some other effects from problems in formatting, however we are not programmers.

wOOge’s picture

I found it seemed to be a problem with Any Menu Path. There is a patch that people are reporting fixes the issue — i have yet to test it:

https://drupal.org/node/2237615

dqd’s picture

Project: Link » Any Menu Path
Status: Postponed (maintainer needs more info) » Closed (duplicate)

move it to Any Menu path ... and close it as duplicate of #2237615: External links are converted to internal links