WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#27684 closed defect (bug) (fixed)

wp_http_validate_url() - PHP Notice: undefined index port

Reported by: jesin Owned by: SergeyBiryukov
Milestone: 3.9 Priority: normal
Severity: normal Version: 3.5.1
Component: HTTP API Keywords: has-patch commit
Focuses: Cc:

Description

If the URL of my WordPress site is http://example.com/ and I pass the same URL with a port number which is NOT 80, 443 or 8080 to the wp_http_validate_url() function the following PHP notice is shown.

Notice:  Undefined index: port in /var/www/wp-includes/http.php on line 513

Code to reproduce the problem.

var_dump ( wp_http_validate_url( 'http://yoursite.com:81' ) );

Output:

Notice:  Undefined index: port in /var/www/wp-includes/http.php on line 513
bool(false)

Expected output:

bool(false)

Attachments (1)

27684.diff (480 bytes) - added by jesin 6 years ago.
Check if index port is set before comparing

Download all attachments as: .zip

Change History (4)

@jesin
6 years ago

Check if index port is set before comparing

#1 @jesin
6 years ago

  • Keywords has-patch added

#2 @SergeyBiryukov
6 years ago

  • Keywords commit added
  • Milestone changed from Awaiting Review to 3.9
  • Version changed from 3.8.1 to 3.5.1

Introduced in [23329], moved to wp_http_validate_url() in [24480].

#3 @SergeyBiryukov
6 years ago

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

In 27953:

Avoid an undefined index notice in wp_http_validate_url().

props jesin.
fixes #27684.

Note: See TracTickets for help on using tickets.