I have a website running in the sub directory for example http://example.com/info.

In the settings.php I have $base_url = 'http://example.com/info'; and in .htaccess I have RewriteBase /info.

When I create a link field and input internal URL (eg. user/login), I get a result with base URL duplicate (eg. http://example.com/info/info/user/login).

This is happening because in the _link_sanitize() function on line 517 we have the following code:

  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' => !empty($instance['settings']['absolute_url']),
      'html' => TRUE,
      )
    );
  }

The link URL gets sanitized and converted into /info/user/login because of the url() function and then, when its processed by the theme_link() at the end, the Drupal will add /info again.

Issue fork link-2898414

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Vlad Stratulat created an issue. See original summary.

Vlad Stratulat’s picture

Issue summary: View changes
Vlad Stratulat’s picture

Issue summary: View changes
Vlad Stratulat’s picture

Issue summary: View changes
Vlad Stratulat’s picture

I've created a patch for this. Can someone review and merge it?

Vlad Stratulat’s picture

It seems like its failing the test but the output is correct.

Vlad Stratulat’s picture

Patching the URL only if the base path is longer then 1 symbol (not just /).

Vlad Stratulat’s picture

Patching the URL only if the base path is longer then 1 symbol (not just /).

coaston made their first commit to this issue’s fork.

DiDebru’s picture

Status: Active » Needs review

We encountered this bug in 7.x-1.11 would be great if the patch could be committed.
Patch looks good.

DamienMcKenna’s picture

Version: 7.x-1.4 » 7.x-1.x-dev
FileSize
0 bytes

This is the file from #7 with a filename that the test infrastructure can use.

DiDebru’s picture

Status: Needs review » Needs work

Patch failed to apply.

DamienMcKenna’s picture

Status: Needs work » Needs review
FileSize
667 bytes

Doh.

DamienMcKenna’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Let's add test coverage to make sure this doesn't break in the future.