WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#29314 closed defect (bug) (fixed)

wp_extract_urls is not returning full url

Reported by: pushplaybang Owned by: wonderboymusic
Milestone: 4.1 Priority: normal
Severity: normal Version: 3.7
Component: General Keywords: has-patch
Focuses: Cc:

Description

wp_extract_urls doesn't seem to return the query part of an extracted url. for example

http://www.youtube.com/watch?v=exvUH2qKLTU

is returned as

http://www.youtube.com/watch

this is an incredibly useful function and surely should be able to handle this sort of URL?

Attachments (2)

wp-functions.php.patch (852 bytes) - added by hauvong 6 years ago.
Patch to fix link containing "?" and issue extracting url from shortcode tags: [shortcode attr="http://.."]http:...[/shortcode]
29314.patch (619 bytes) - added by dlh 6 years ago.
Update test_wp_extract_urls()

Download all attachments as: .zip

Change History (8)

#1 @SergeyBiryukov
6 years ago

  • Version changed from 3.9.2 to 3.7

Note that the function is primarily used for pings/trackbacks (it was added in [25313] for #9064).

@hauvong
6 years ago

Patch to fix link containing "?" and issue extracting url from shortcode tags: [shortcode attr="http://.."]http:...[/shortcode]

#2 @hauvong
6 years ago

I had similar issue where we have shortcode in the form [shortcode image="http://.."]http://..[/shortcode]
the function would extract the url value as: http://..."]http://..

Attached patch file is the suggest modification to fix both issues.

#3 @SergeyBiryukov
6 years ago

  • Keywords has-patch needs-unit-tests added

@dlh
6 years ago

Update test_wp_extract_urls()

#4 @dlh
6 years ago

This patch adds a URL of the form reported here to test_wp_extract_urls(). Are additional URLs or tests needed?

#5 @SergeyBiryukov
6 years ago

  • Keywords needs-unit-tests removed
  • Milestone changed from Awaiting Review to 4.1

#6 @wonderboymusic
6 years ago

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

In 29756:

wp_extract_urls() needs to also grab URLs with query strings and hashes.

Updates unit test.

Props hauvong, dlh.
Fixes #29314.

Note: See TracTickets for help on using tickets.