Problem/Motivation

If user passes an external url after the domain, Drupal site with enabled Menu Trail By Path module throws InvalidArgumentException.

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

Steps to reproduce

  1. Install Drupal core.
  2. Visit a url inside your Drupal like http://your.drupal/http://example.com/node/4. You should get a 404 Page not found message.
  3. Now enable this module and try to visit the same url given above.

Proposed resolution

In the CurrentPathHelper class, instead of using Url::fromUserInput() directly, use PathValidator::getUrlIfValid() method and also check that the returned variable is an Url object.

Remaining tasks

Provide a patch.

User interface changes

None.

API changes

None.

Data model changes

None.

Comments

huzooka created an issue. See original summary.

huzooka’s picture

Assigned: huzooka » Unassigned
Status: Active » Needs review
StatusFileSize
new1.18 KB

Status: Needs review » Needs work

huzooka’s picture

Status: Needs work » Needs review
StatusFileSize
new1.37 KB

  • davy-r committed 1b77724 on 8.x-1.x
    Issue #2810961: CurrentPathHelper assumes that path components are...
davy-r’s picture

Status: Needs review » Fixed

I solved it with a different approach, to avoid other issues.. Thanks for reporting and contributing huzooka!

Status: Fixed » Closed (fixed)

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