Problem/Motivation
I noticed in my logs that a referrer is using https://www.example.com// to direct users to my site. Notice the double slash. The site seems to get redirected to a single slash which is great, but the following PHP warning still occurs when AliasManager->getAliasByPath('//') is called by a contrib module’s (protected_pages) KernelEvents::RESPONSE event subscriber.
Warning: array_key_exists(): The first argument should be either a string or an integer in Drupal\Core\Path\AliasWhitelist->get() (line 120)
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | URL alias.png | 39.44 KB | mitthukumawat |
| #2 | 3215098-fix-getAliasByPath-with-multiple-slash-9.2.x-2.patch | 761 bytes | daniel korte |
| #2 | 3215098-fix-getAliasByPath-with-multiple-slash-8.9.x-2.patch | 753 bytes | daniel korte |
Comments
Comment #2
daniel korteComment #3
mitthukumawat commentedI have applied the patch in drupal 9.3.x-dev version and it is working as expected.
Testing steps:
# Added a new url alias having // in alias to redirect on another existing page.
# Accessed this url and getting
Warning: array_key_exists(): The first argument should be either a string or an integer in Drupal\path_alias\AliasWhitelist->get() (line 95 of /var/www/html/Contribution/93dev/codebase/core/modules/path_alias/src/AliasWhitelist.php)# Applied patch and accessed the page having // in url alias.
# PHP error not appearing now.
Adding screenshot for reference.
Comment #8
smustgrave commentedThis issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.
Did not test the issue but will need a test case to demonstrate the issue please
Thanks.
Comment #9
douggreen commentedThe problem is more pervasive than this. If you visit /index.php5, something takes everything after "index.php" as the path alias, and you end up here with the path part set to "5" which throws an error.