Closed blimpage closed 8 months ago
Just pushed an update: this fix originally used str_replace()
, but I realised that this would also remove too many characters from the path in edge cases where CC_ROOT_REL
happens to appear in the path multiple times. I've updated this now to use a regex replacement anchored to the start of the string, so it should only remove CC_ROOT_REL
when it appears at the very start of the path.
Thanks so much for this.
Rather than removing instances of an entire search string from the supplied input string,
ltrim()
removes all characters from the input string that appear anywhere in the search string, until it finds the first character in the input string that doesn't appear in the search string.When used here in adding URLs to the 404 log table, this means that sometimes additional parts of the URL's path will be removed, depending on your site's
CC_ROOT_REL
.For example, with the URL
https://example-site.com/online-store/index.php
, the site'sCC_ROOT_REL
will be/online-store/
, soltrim()
will trim the URL todex.php
since thei
andn
characters at the start of the path appear inCC_ROOT_REL
.d
does not appear inCC_ROOT_REL
, so all characters from that point on are preserved.Using
preg_replace()
instead ensures that only the exactCC_ROOT_REL
string is removed from the beginning of the logged URL.Related
There's another use of
ltrim()
in settings.language.inc.php that looks like it also might trim URLs too aggressively, but I'm not familiar with the context of that code so I haven't touched it here.