Make WordPress Core

Opened 11 years ago

Closed 11 years ago

#32059 closed defect (bug) (fixed)

Media views EmbedLink should check for empty url string

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

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 11 years ago.

Download all attachments as: .zip

Change History (6)

#1 @afercia
11 years ago

  • Keywords needs-patch added

#2 @afercia
11 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
11 years ago

  • Description modified (diff)

#4 @wonderboymusic
11 years ago

  • Keywords has-patch added; needs-patch removed
  • Milestone Awaiting Review4.3
  • Owner set to wonderboymusic
  • Status newassigned

#5 @wonderboymusic
11 years ago

  • Resolutionfixed
  • Status assignedclosed

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.