Opened 7 years ago
Last modified 13 months ago
#49633 new defect (bug)
Trim cookie paths
| Reported by: | Kevin Brent | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Login and Registration | Version: | 5.3.2 |
| Severity: | normal | Keywords: | has-patch has-unit-tests |
| Cc: | Focuses: |
Description
I had just migrated a WP website that was very old. I encountered an issue that took several hours to debug.
The site was on PHP 5.6 and I updated everything to use PHP 7.3. At PHP 5.6 this was not an issue, but was at PHP 7.3.
The site seemed to be loading fine. No errors in the PHP error logs. However, I was not able to login to the WP Admin. After I defined error logging true. I get this:

After several hours of debugging I found this:

I was able to fix this in the DB. But, feel that WP could simply trim
spaces from cookie paths since they are not allowed by PHP.
There are 3 constants that require this attention.
COOKIEPATH
SITECOOKIEPATH
PLUGINS_COOKIE_PATH
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)

This PR ensures that cookie path constants are trimmed so that accidental leading or trailing whitespace in
home,siteurl, or plugin URLs cannot create invalid cookie paths.Affected constants:
COOKIEPATH,SITECOOKIEPATH,PLUGINS_COOKIE_PATH(defined indefault-constants.php)Code used for testing:
Trac ticket: https://core.trac.wordpress.org/ticket/49633