WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 9 months ago

#36369 closed enhancement (fixed)

esc_url(): strip leading whitespace characters

Reported by: toszcze Owned by: pento
Milestone: 5.3 Priority: normal
Severity: normal Version: 2.8
Component: Formatting Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

I to strip leading whitespace characters form the URL passed to esc_url() function.

At the moment if we pass an URL with leading spaces (or other whitespace characters) to esc_url(), it returns an empty string, even if the URL is correct.

Attachments (3)

36369.diff (459 bytes) - added by toszcze 4 years ago.
36369_test.diff (1011 bytes) - added by toszcze 4 years ago.
Unit test
36369.2.diff (1.5 KB) - added by pento 9 months ago.

Download all attachments as: .zip

Change History (9)

@toszcze
4 years ago

#1 @toszcze
4 years ago

  • Keywords has-patch added

#2 follow-up: @swissspidy
4 years ago

  • Keywords needs-unit-tests added

What about trailing whitespace?

#3 in reply to: ↑ 2 @toszcze
4 years ago

Trailing spaces are correctly replaced by %20. I don't know if there is any case when trailing spaces in an URL would be necessary, but personally I would leave them, because they are not causing any issues.

@toszcze
4 years ago

Unit test

#4 @johnbillion
4 years ago

  • Keywords has-unit-tests added; needs-unit-tests removed
  • Milestone changed from Awaiting Review to Future Release
  • Version changed from 4.4.2 to 2.8

@pento
9 months ago

#5 @pento
9 months ago

  • Milestone set to 5.3
  • Owner set to pento
  • Status changed from new to assigned

36369.2.diff combines and refreshes the patches to apply cleanly against trunk.

#6 @pento
9 months ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 45578:

Formatting: Trim leading whitespace in esc_url().

Props toszcze.
Fixes #36369.

Note: See TracTickets for help on using tickets.