Absolute URL in Redirect From causes PHP Error.

Created on 18 December 2023, 11 months ago
Updated 1 January 2024, 11 months ago

Problem/Motivation

Although the Redirect add form asks for "path" and prefaces the input with the site base url, it does not throw a validation error if a user inadvertently adds an absolute URL for the "from" field. When this happens, it throws a PHP error in the redirect_extensions view, as the link is rewritten using the substitution pattern {{ redirect_source__path }}, producing the error:

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

Steps to reproduce

Install redirect extensions and create a redirect with an absolute URL as the "from" url. Then load /admin/config/search/redirect

Proposed resolution

In the link rewrite, check if the URL starts with /https:// or /http://. If so, just use the raw path for the rewrite rather than the redirect_source__path object.

πŸ› Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States dgroene

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024