Problem/Motivation

Previously it was possible to set views more link to point to an external URL. At some point it got hard coded to be considered as internal link which makes it not possible to link it to external URL.

Proposed resolution

Don't hard code the internal:/ into the URL

Remaining tasks

-

User interface changes

-

API changes

-

Data model changes

-

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

lauriii created an issue. See original summary.

dawehner’s picture

Meh :)

lauriii’s picture

Title: Views more link cannot point to external link » Views more link cannot point to an external URL

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

calebtr’s picture

I came looking for this because I was seeing a similar error as https://www.drupal.org/node/2488540.

So other folks can find this issue, the error message is:

InvalidArgumentException: The internal path component 'http://...' is external. You are not allowed to specify an external URL together with internal:/. in Drupal\Core\Url::fromInternalUri() (line 430 of .../core/lib/Drupal/Core/Url.php).

In my use case, I'd like a block view of aggregator feed items to have a 'more' link that goes to the original source. I solved it, temporarily, with an Apache redirect from an internal path, which is not ideal.

It seems like this is part of the much bigger problem of views applying its own rules for how users enter urls. I looked and haven't found an issue for that yet. If this issue is worth working on, where to start?

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

racinggrinner’s picture

+1 To get this fixed. Also fails to link to arguments such as: /resources/library?field_resource_type_target_id=43

Cellar Door’s picture

Version: 8.5.x-dev » 8.6.x-dev
FileSize
850 bytes

Ran into this one as well and found a quick and easy fix to check if it's external url via starting with http. I'm sure there are other tests etc. that will need to be eventually written but for anyone wanting a patch here you go.

dawehner’s picture

+++ b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php
@@ -2078,7 +2078,11 @@ public function renderMoreLink() {
+        if(strpos($path, 'http') === 0){

How about using \Drupal\Component\Utility\UrlHelper::isExternal instead?

Shane Birley’s picture

I just ran into this creating an XML feed using Views. The error appears when attempting to view the feed. Incredibly odd.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

nightlife2008’s picture

I recreated the patch using the UrlHelper function.

Nathan Tsai’s picture

Along with @ShaneBirley, I've also encountered this while trying to make an RSS feed.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

chaquea’s picture

Rolling against 8.7 based on #15

idebr’s picture

Lendude’s picture

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

We have a patch, so lets see what the TestBot makes of this, but this still needs a test.

yogeshmpawar’s picture

Assigned: Unassigned » yogeshmpawar
yogeshmpawar’s picture

Assigned: yogeshmpawar » Unassigned
FileSize
1.51 KB
1.17 KB

Resolved coding standard issue & added an interdiff.

daffie’s picture

Status: Needs review » Needs work

There is an automated test needed. The fix looks good to me!

daffie’s picture

For the comitter: please give credit to @evanjenkis and @boazpoolman. There patches are older then the patches from this issue. See: #2806751: More link external URL errors out.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

chaquea’s picture

Patch 2556349-22.patch does not apply to core 8.8.1, but it seems like this was implemented into core already?

core/modules/views/src/Plugin/views/display/DisplayPluginBase.php (line 2127)

$url = UrlHelper::isExternal($path) ? Url::fromUri($path, $options) : Url::fromUserInput('/' . ltrim($path, '/'), $options);

Lendude’s picture

Status: Needs work » Closed (outdated)

Yup this got fixed in #564106: More links pointing to custom URLs don't respect entered fragments and query parameters, this should have been closed as a duplicate of that :(

Thanks for working on this anyway!