Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#32059 closed defect (bug) (fixed)

Media views EmbedLink should check for empty url string

Reported by: afercia's profile afercia Owned by: wonderboymusic's profile wonderboymusic
Milestone: 4.3 Priority: normal
Severity: normal Version: 4.1
Component: Media Keywords: has-patch
Focuses: ui, javascript Cc:

Description (last modified by afercia)

Splitting this out from #29476. Noticed one small thing: embedding a URL in the "Insert from URL" field should handle also the case when users empty the field. To reproduce;

Edit/create a post then go in Add Media > Insert from URL

  • paste an embeddable URL
  • then empty the field
  • at this point url is an empty string
  • the AJAX call fires
  • the "Link Text" field appears

You will also see a PHP notice in your console:

<b>Notice</b>:  Undefined variable: url in <b>.../ajax-actions.php</b> on line <b>2749

looks like this check in this line in /wp-includes/js/media/views/embed/link.js

if ( url && url.length < 6 ) {
  ...

should also check when url is falsey.

Also, not sure why 6 characters :) http:// is made by 7 characters but maybe I'm missing something.

Attachments (1)

32059.diff (1.4 KB) - added by wonderboymusic 9 years ago.

Download all attachments as: .zip

Change History (6)

#1 @afercia
9 years ago

  • Keywords needs-patch added

#2 @afercia
9 years ago

My bad :) looks like the PHP notice was just in trunk and r32258 fixed it. Would recommend to still consider this ticket for the useless AJAX call to avoid and the "Link Text" field that shouldn't appear when emptying the URL field.

#3 @afercia
9 years ago

  • Description modified (diff)

@wonderboymusic
9 years ago

#4 @wonderboymusic
9 years ago

  • Keywords has-patch added; needs-patch removed
  • Milestone changed from Awaiting Review to 4.3
  • Owner set to wonderboymusic
  • Status changed from new to assigned

#5 @wonderboymusic
9 years ago

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

In 32463:

In EmbedLink, a URL needs to be at least 11 chars to be useful.

Fixes #32059.

Note: See TracTickets for help on using tickets.