WordPress.org

Make WordPress Core

Opened 2 years ago

#36873 new defect (bug)

Canonical redirect code does opposite of comment, breaks script when home_url starts with https

Reported by: thasmin Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.5.2
Component: Canonical Keywords:
Focuses: Cc:

Description

The comment on line 444 in wp-includes/canonical.php says that it only changes the host if it's adding or removing "www.". It changes the host to lowercase if capitalization is the only difference or if the change is NOT adding or removing "www.". Either the comment or the code should be changed.

This is causing a problem when I try to run the script below. If the home url (used on line 176) is "https://www.example.com/", then the host is removed and redirect url changes to "https:///". This makes the parse_url call on line 69 return false and end processing.

I believe this is why the script fails. There's a lot of code here. Apologies if I have it wrong.

Here's the script: define('WP_USE_THEMES', true); require_once('/var/www/html/wp-blog-header.php');

I can workaround the bug by explicitly setting some server variables before calling that code: $_SERVER = array (

'REQUEST_URI' => '/', 'HTTPS' => 'on', 'HTTP_HOST' => 'www.example.com',

);

Change History (0)

Note: See TracTickets for help on using tickets.