Leading space is being stripped from "From" path; proposed fix

Created on 8 August 2014, almost 11 years ago
Updated 20 May 2025, about 4 hours ago

If the From field contains a leading space, it is being stripped, making it impossible to redirect to the same path without the leading space.

For example, an external site is pointing to "mysite.com/ alias/fullpath", with a space before 'alias'. The From field is set as " alias/fullpath" and To is set as "alias/fullpath", but the module thinks these are identical.

A quick fix was to remove the space from the trim mask in redirect.module, line 1310:
$url = trim($url, " \t\n\r\0\x0B\/");

The problem is, any trailing spaces will cause the redirect to fail, since browsers will strip them when the URL is entered. To resolve this, rtrim was added specifically to remove trailing whitespace, resulting in the following proposed fix:
$url = rtrim(trim($url, "\t\n\r\0\x0B\/"), " ");

πŸ› Bug report
Status

Closed: outdated

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States wsantell

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024