Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
-
Comment | File | Size | Author |
---|---|---|---|
#22 | interdiff-2556349-18-22.txt | 1.17 KB | yogeshmpawar |
#22 | 2556349-22.patch | 1.51 KB | yogeshmpawar |
Comments
Comment #2
dawehnerMeh :)
Comment #3
lauriiiComment #5
calebtr CreditAttribution: calebtr commentedI 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?
Comment #10
racinggrinner CreditAttribution: racinggrinner commented+1 To get this fixed. Also fails to link to arguments such as: /resources/library?field_resource_type_target_id=43
Comment #11
Cellar Door CreditAttribution: Cellar Door at Cellar Door commentedRan 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.
Comment #12
dawehnerHow about using
\Drupal\Component\Utility\UrlHelper::isExternal
instead?Comment #13
Shane Birley CreditAttribution: Shane Birley commentedI just ran into this creating an XML feed using Views. The error appears when attempting to view the feed. Incredibly odd.
Comment #15
nightlife2008 CreditAttribution: nightlife2008 commentedI recreated the patch using the UrlHelper function.
Comment #16
Nathan Tsai CreditAttribution: Nathan Tsai commentedAlong with @ShaneBirley, I've also encountered this while trying to make an RSS feed.
Comment #18
chaquea CreditAttribution: chaquea as a volunteer commentedRolling against 8.7 based on #15
Comment #19
idebr CreditAttribution: idebr at iO commentedClosed #3062542: Views 'More Link' not allowing external links as a duplicate issue.
Comment #20
LendudeWe have a patch, so lets see what the TestBot makes of this, but this still needs a test.
Comment #21
yogeshmpawarComment #22
yogeshmpawarResolved coding standard issue & added an interdiff.
Comment #23
daffie CreditAttribution: daffie commentedThere is an automated test needed. The fix looks good to me!
Comment #24
daffie CreditAttribution: daffie commentedFor 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.
Comment #26
chaquea CreditAttribution: chaquea as a volunteer commentedPatch 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);
Comment #27
LendudeYup 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!