From cbaa63caeb9be4556b3dc88e667d0c82096c52c6 Mon Sep 17 00:00:00 2001 From: Drew Jaynes Date: Wed, 16 Aug 2017 21:10:39 +0000 Subject: [PATCH] Canonical: Check first before attempting to include a 'path' value in the URL in `strip_fragment_from_url()`. Props Mte90. Fixes #40542. git-svn-id: https://develop.svn.wordpress.org/trunk@41257 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/canonical.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/canonical.php b/src/wp-includes/canonical.php index dfa6ec515d..12b2445aa1 100644 --- a/src/wp-includes/canonical.php +++ b/src/wp-includes/canonical.php @@ -568,7 +568,11 @@ function strip_fragment_from_url( $url ) { if ( ! empty( $parsed_url['port'] ) ) { $url .= ':' . $parsed_url['port']; } - $url .= $parsed_url['path']; + + if ( ! empty( $parsed_url['path'] ) ) { + $url .= $parsed_url['path']; + } + if ( ! empty( $parsed_url['query'] ) ) { $url .= '?' . $parsed_url['query']; }