Make WordPress Core

Opened 7 years ago

Last modified 5 weeks ago

#46791 reopened defect (bug)

esc_url() adding http:// to a relative URL to parent directory '../pathname/'

Reported by: orangepixelnath's profile OrangePixelNath Owned by:
Milestone: 7.0 Priority: normal
Severity: normal Version: 5.1
Component: Formatting Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

esc_url() adds 'http://' when it shouldn't.

Line 4191 wp-includes/formatting.php states

If the URL doesn't appear to contain a scheme, we presume it needs http:// prepended (unless a relative link starting with /, # or ? or a php file).

This is prepending http:// to a relative url to a parent directory i.e. ../path-to-page/

Funtion needs ../ adding to the array or some regex code.

Attachments (2)

46791.diff (633 bytes) - added by subrataemfluence 7 years ago.
Proposed patch.
46791-2.diff (782 bytes) - added by subrataemfluence 7 years ago.
Corrected patch.

Download all attachments as: .zip

Change History (11)

#1 @SergeyBiryukov
7 years ago

  • Component changed from General to Formatting

@subrataemfluence
7 years ago

Proposed patch.

@subrataemfluence
7 years ago

Corrected patch.

#2 @OrangePixelNath
7 years ago

  • Resolution set to worksforme
  • Status changed from new to closed

#3 @OrangePixelNath
7 years ago

  • Keywords needs-patch added

#4 follow-up: @desrosj
7 years ago

  • Keywords has-patch added; needs-patch removed

@OrangePixelNath did you mean to close this ticket? If so, can you detail why? What did you discover that made your report incorrect or unnecessary?

#5 in reply to: ↑ 4 @OrangePixelNath
7 years ago

  • Resolution worksforme deleted
  • Status changed from closed to reopened

Replying to desrosj:

@OrangePixelNath did you mean to close this ticket? If so, can you detail why? What did you discover that made your report incorrect or unnecessary?

No sorry. I'm new to the system so didn't understand what was next.

#6 @desrosj
7 years ago

  • Keywords needs-testing added

No problem! That’s why I checked to be sure :)

Next, the ticket stays open for community members to text and review.

Last edited 7 years ago by desrosj (previous) (diff)

#7 @r1k0
5 weeks ago

  • Keywords needs-refresh added; needs-testing removed

The patch doesn't apply cleanly; it fails with the error:

Running "patch:46791" (patch) task
? Please select a patch to apply 46791-2.diff​ (782 bytes) - adde
d by subrataemfluence 7 years ago.
patching file wp-includes/formatting.php
Hunk #1 FAILED at 4190.
1 out of 1 hunk FAILED -- saving rejects to file wp-includes/formatting.php.rej

Patch needs a refresh and removing needs-testing.

This ticket was mentioned in PR #10849 on WordPress/wordpress-develop by @sabernhardt.


5 weeks ago
#8

  • Keywords has-unit-tests added; needs-refresh removed

Does not prepend the fallback protocol when the reference starts with a dot (./ or ../).

Trac 46791

#9 @sabernhardt
5 weeks ago

  • Milestone changed from Awaiting Review to 7.0
Note: See TracTickets for help on using tickets.