Uncaught PHP Exception InvalidArgumentException: "The internal path component 'http://localhost/XXX/node/1' is external. You are not allowed to specify an external URL together with internal:/." at /private/var/www/drupal/core/lib/Drupal/Core/Url.php line 410

If you used absolute URL or you used attached link field to content type you will get a bove error.

It is important to concat the URL with internal and why its here.

Removing internal will solve the problem.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

m.abdulqader created an issue. See original summary.

m.abdulqader’s picture

FileSize
733 bytes
Janec’s picture

I had the same problem and patch #2 solved it.
Thanks.
PS: But it breaks the link to node wrapper.

geekygnr’s picture

This patch works for my issue. Something else I found was patch #3 in https://www.drupal.org/node/2824892

It contains a check to insure that the url is marked as internal. Not sure if that is also needed.

geekygnr’s picture

FileSize
450 bytes

I made a patch based on above

m.abdulqader’s picture

strpos($url, 'internal:/') don't check for internal paths, As per documentation we should use UrlHelper::isExternal.

I updated the patch to work for internal and external.

m.abdulqader’s picture

FileSize
1.09 KB

The last patch will solve part of the problem, the main issue is that token is returning URL with "internal:" in the beginning and that's not happened for "link to content".

The attached patch will handle all cases.

m.abdulqader’s picture

Status: Active » Needs review
Cauliflower’s picture

An internal path can also start with base:, entity:, ... so only checking for internal: is not sufficient.

The patch attached checks if an uri scheme is defined, if not it adds the internal scheme. In that case there will be no error to render the link, but the page won't be found (eg. given: 'google.be' will become 'internal:google.be' and rendered as /google.be).

damontgomery’s picture

Status: Needs review » Reviewed & tested by the community

We have been using #9 and the code makes sense to me. I've marked this as tested. Please move back if that isn't appropriate.

  • swentel committed bbfff2f on 8.x-3.x authored by Cauliflower
    Issue #2883928 by m.abdulqader, geekygnr, Cauliflower: Use absolute or...

  • swentel committed c2fb819 on 8.x-4.x authored by Cauliflower
    Issue #2883928 by m.abdulqader, geekygnr, Cauliflower: Use absolute or...
swentel’s picture

Status: Reviewed & tested by the community » Fixed

committed and pushed, thanks everyone!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.