Make WordPress Core

Opened 7 years ago

Last modified 3 years ago

#30580 new defect (bug)

wp_extract_urls not returning full URL with & query separator

Reported by: trex005 Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.7
Component: Formatting Keywords: has-patch
Focuses: Cc:


Related : 29314

When formatting a link, and even when inserting a URL in the visual editor in WordPress the & separator used for the query variables will be properly encoded into &. However, when you then pass that string to wp_extract_urls, it incorrectly truncates the URL at the &.

Example :

Attachments (2)

30580.diff (1.1 KB) - added by voldemortensen 7 years ago.
30580.2.diff (1.2 KB) - added by voldemortensen 7 years ago.

Download all attachments as: .zip

Change History (6)

#1 @johnbillion
7 years ago

  • Component changed from General to Formatting
  • Keywords needs-patch needs-unit-tests added
  • Version changed from trunk to 3.7

Thanks for the report!

7 years ago

#2 @voldemortensen
7 years ago

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

Fixes the regex used in wp_extract_urls. Adds unit tests.

#3 @johnbillion
7 years ago

Those tests could probably benefit from some URLs with trailing punctuation, eg. http://example.com;.

#4 @voldemortensen
7 years ago

I was just writing a comment saying that the ; character would now be allowed in urls, which has the potential to allow broken urls. But I think its better to allow some broken urls (we can't help if someone enters a bad link), than to not allow valid urls. Adding patch with suggested unit tests.

Last edited 7 years ago by voldemortensen (previous) (diff)
Note: See TracTickets for help on using tickets.