Needs review
Project:
Customerror
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
13 Nov 2026 at 01:52 UTC
Updated:
13 Nov 2026 at 08:48 UTC
Jump to comment: Most recent
_customerror_login_submit() runs on every login form. It is what sends a user who logs in from the 403 page back to the page they were denied. It has three bugs:
else branch then sets the query destination to NULL. /user/login?destination=/node/1 lands on the user page.Url::fromUserInput(), which throws unless it starts with /, ? or #.Url::fromUserInput() adds it again. On a site in a subdirectory, logging in from the 403 page gives a 404./user/login?destination=/node/1. You land on your user page.destination=node/1. The response is a 500.else./.RedirectResponseSubscriber does.Tests:
?destination on the login page is honored (fails on HEAD).Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
loze commentedComment #3
loze commentedComment #5
loze commentedComment #6
loze commentedComment #7
loze commentedComment #8
loze commentedComment #9
loze commentedComment #10
loze commentedComment #11
nitinkumar_7 commentedThe changes look good overall. I have suggestion regarding test coverage:
Could we add a test to verify that an external destination is rejected? Since the new implementation explicitly checks UrlHelper::isExternal(), it would be good to cover this behaviour.
Comment #12
nitinkumar_7 commentedCould we also test the redirect on an actual subdirectory installation? The current base-path test is useful, but it doesn't appear to reproduce that exact environment.
This would give us better coverage for the reported issues.
Comment #13
loze commentedThanks for the review.
I added a kernel test,
LoginSubmitHandlerTest, that postshttps://example.com/and//example.com/to the submit handler and checks that no redirect is set. It calls the handler directly because core's request sanitizer removes external destinations before a real request gets that far. The test-only job shows both cases failing on the current code.You're right about the subdirectory test. The pipeline installs the site at
/web, and the same test-only job showstestPostedDestinationKeepsBasePathpassing on the current code, so it wasn't testing the bug. I removed it. The doubled base path shows up when you log in from the login form on the 403 page. Testing that needs theenable_loginschema that #3637882: 403 page starts a session for every anonymous visitor, which bypasses the page cache adds, so I'll add that test once it's in.