Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#55333 closed defect (bug) (fixed)

PHP Notice in strip_fragment_from_url() when schemeless URI is passed

Reported by: dd32's profile dd32 Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 6.0 Priority: normal
Severity: normal Version:
Component: Canonical Keywords: has-patch
Focuses: Cc:

Description

Related to [52829] is this PHP Notice that seems to be triggering on a the_content filter after that change:

GET https://wordpress.org/news/2014/04/smith/

E_NOTICE: Undefined index: scheme in wp-includes/canonical.php:854
Undefined index: scheme

The input in this case is a URL such as //wordpress.org/news/files/2014/04/widgets.mp4.

I also note that strip_fragment_from_url() doesn't use wp_parse_url() but uses parse_url() directly.

Change History (5)

This ticket was mentioned in PR #2385 on WordPress/wordpress-develop by dd32.


3 years ago
#1

  • Keywords has-patch added

#2 @SergeyBiryukov
3 years ago

  • Milestone changed from Awaiting Review to 6.0

#3 @SergeyBiryukov
3 years ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 52833:

Canonical: Check if the URL scheme exists in strip_fragment_from_url().

This avoids an "Undefined index" PHP notice when a schemeless URI is passed.

Props dd32, SergeyBiryukov.
Fixes #55333.

#5 @SergeyBiryukov
3 years ago

For reference, strip_fragment_from_url() was added in [35770] / #19918.

Note: See TracTickets for help on using tickets.