Problem/Motivation
When an anonymous user wants to open a URL which is only accessible to authenticated users, e.g. https://www.example.com/intranet, then they get redirected to the login form and after that probably to the legal_confirm page. That redirect to legal_confirm contains the url argument destination=intranet/ which then leads to this error:
InvalidArgumentException: The user-entered string 'intranet/' must begin with a '/', '?', or '#'. in Drupal\Core\Url::fromUserInput() (Zeile 214 in /var/www/drupal/wohnen/develop/web/core/lib/Drupal/Core/Url.php).
When a user had accepted the T&C before already, the above scenario also redirects to the user login form with the same url argument destination=intranet/, which then redirects correctly.
Not sure yet, why the same destination argument works in one but not the other scenario.
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | 3251628_redirect_url_3.patch | 2.84 KB | alecsmrekar |
| #10 | 3251628_redirect_url_2.patch | 3.05 KB | alecsmrekar |
| #9 | 3251628_redirect_url_1.patch | 3.06 KB | alecsmrekar |
| #6 | 3251628_redirect_url.patch | 1.29 KB | alecsmrekar |
Issue fork legal-3251628
Show commands
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 #3
jurgenhaasFound the issue in
\Drupal\legal\Form\LegalLogin::submitFormand fixed it in the MR3Comment #4
mkolar commentedHad same issue, this works for me. I would say RTBC
Comment #5
juliekramer commentedI had same issue where the redirect to legal_confirm contains the url argument "destination=something", this fixes the issue
Comment #6
alecsmrekar commentedIf the current patch is applied we end up with 2 issues.
#1 The default redirect to /user/ID is broken. You can't use "//user/ID" as a path. That's why the test is failing.
#2 Url destination parameters can come with or without a leading forward slash. Both need to be taken into account.
I'm attaching a patch that mitigates both issues. It also generates the user URL in better way, URL hardcoding should be avoided.
Comment #7
alecsmrekar commentedComment #8
plachLet's use the
redirect.destinationservice, since we're touching this line.Comment #9
alecsmrekar commentedFixed in this patch. I also removed some unused class properties:
$database,$moduleHandler, and$languageManager.Comment #10
alecsmrekar commentedFixing the last patch
Comment #11
alecsmrekar commentedAdded a fix to prevent the from from redirecting to itself.
Comment #12
anybody@alecsmrekar please don't use patches on an issue where a MR was used. Please incorporate the (only issue related!!) changes into the MR so we can see the interdiff. All other changes should go into separate issues please.
Comment #13
jaydarnellThis no longer appears to be an issue. As mentioned above, the initial patch supplied here: https://git.drupalcode.org/project/legal/-/merge_requests/3.patch actually breaks the redirect altogether (in the 3.x branch at least). After I removed this patch I attempted to recreate the initial bug reported in this issue but cannot. I suspect the problem was fixed elsewhere and this issue merely needs to be closed.
Comment #14
frobI have not tried any of the patches, however, I can confirm that this issue is still present on 3.0.1
Comment #15
anybodySo do we need a new stable release or is this also still happening in 3.0.x @frob?
Comment #16
frobI am unable to test the new version at the moment. However, the test is pretty simple. If you visit `/user/login?destination=internet` then it should break with the OP's error.
To fix this ourselves we patched the `public/modules/contrib/legal/src/Form/LegalLogin.php` file to ensure the destination is valid. It looks like you where leaning toward a solution which involved the redirection service so I didn't submit my patch.
Replace
with
Comment #18
robert castelo commented