Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#34144 closed defect (bug) (fixed)

`url_to_postid` doesn't recognize URLs with wrong scheme

Reported by: swissspidy Owned by: wonderboymusic
Milestone: 4.4 Priority: normal
Severity: normal Version: 1.0
Component: Rewrite Rules Keywords: has-patch has-unit-tests
Focuses: Cc:


While working on the oEmbed feature plugin I noticed that url_to_postid doesn't recognize URLs with the wrong URL scheme.

When your site runs HTTPS and you pass a permalink with http://, you won't get the post ID. The same goes when you provide a https:// URL and is_ssl() is false.

A simple set_url_scheme( $url ) fixes this. Patch attached.

Attachments (1)

34144.diff (2.1 KB) - added by swissspidy 6 years ago.

Download all attachments as: .zip

Change History (5)

6 years ago

#1 @johnbillion
6 years ago

  • Keywords has-unit-tests added
  • Milestone changed from Awaiting Review to Future Release

Previously: #33109

#2 @johnbillion
6 years ago

  • Milestone changed from Future Release to 4.4

#3 @swissspidy
6 years ago

#33109 was not for this function, but yes, it's kinda related.

#4 @wonderboymusic
6 years ago

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

In 34890:

Rewrite/Permalinks/Canonical: in url_to_postid(), call set_url_scheme() on the URL to combat mixed content issues and find posts cross-scheme.

Adds unit tests.

Props swissspidy.
Fixes #34144.

Note: See TracTickets for help on using tickets.