Make WordPress Core

Opened 2 days ago

Last modified 38 hours ago

#65068 new defect (bug)

PHP warnings when a registered oEmbed provider is malformed

Reported by: bradshawtm's profile bradshawtm Owned by:
Milestone: Awaiting Review Priority: normal
Severity: minor Version:
Component: Embeds Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

There's no gate to ensure oEmbed providers are valid, so when they're not, one gets these warnings:

PHP Warning:  Undefined array key 0 in /var/www/html/wp-includes/class-wp-oembed.php on line 276
PHP Warning:  Undefined array key 1 in /var/www/html/wp-includes/class-wp-oembed.php on line 276

To reproduce:

First, add an mu-plugin (this same errant structure was seen in the wild):

<?php
add_filter(
	'oembed_providers',
	function ( $providers ) {
		$providers['bad_provider'] = array(
			'url'      => '#https?://example\.site/.*#i',
			'endpoint' => 'https://example.site/api/oembed',
		);
		return $providers;
	}
);
  1. Go to a new post page.
  2. Paste a URL that doesn't have an oEmbed, e.g. https://en.wikipedia.org/wiki/Rickrolling
  3. Do NOT click "Convert to link".
  4. Refresh the post.

Each refresh will show the set of warnings.

Change History (1)

This ticket was mentioned in PR #11568 on WordPress/wordpress-develop by @sukhendu2002.


38 hours ago
#1

  • Keywords has-patch has-unit-tests added

Trac ticket: https://core.trac.wordpress.org/ticket/65068

## Use of AI Tools

Note: See TracTickets for help on using tickets.