Problem/Motivation
I've found an edge case in my web server configuration that can result in Drupal processing the path "//". This module crashes on that value.
Steps to reproduce
Set up Drupal with this module on a web server that somehow allows multiple slashes. E.g. for Apache2, add the directive "MergeSlashes OFF" in the top-level config. Load the path "//" as an anonymous user.
It's worth noting that I DO have my web server merging slashes in production. However, somehow Drupal can still end up processing "//" as the path. I'm still tracking down the error from that direction, but it happens due to some combination of redirects.
Proposed resolution
The problem is in PageCacheAlter->set(), line 70. This line checks to see if $path is "/", and otherwise runs an rtrim on $path. If $path is "//", this results in an empty string. This empty string then gets passed to AliasManager->getAliasByPath() on the next line, which throws an InvalidArgumentException.
I suppose this would crash for a $path that is any number of consecutive slashes (e.g. "////"). A solution would be to check for that case instead of checking for "/" only.
Comments