oEmbed: if SimpleXMLElement does not exist, return an HTTP Error 501 Not implemented response.

Props swissspidy.
Fixes #34274.

Built from https://develop.svn.wordpress.org/trunk@35354


git-svn-id: http://core.svn.wordpress.org/trunk@35320 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2015-10-22 16:38:26 +00:00
parent 31e0b06125
commit 1cd49e2d4d
3 changed files with 11 additions and 3 deletions

View File

@ -142,12 +142,17 @@ final class WP_oEmbed_Controller {
* @return string The XML response data.
*/
public function xml_response( $data ) {
if ( ! class_exists( 'SimpleXMLElement' ) ) {
status_header( 501 );
return get_status_header_desc( 501 );
}
$result = _oembed_create_xml( $data );
// Bail if there's no XML.
if ( ! $result ) {
status_header( 501 );
return 'Not implemented';
return get_status_header_desc( 501 );
}
if ( ! headers_sent() ) {

View File

@ -351,7 +351,10 @@ function wp_oembed_add_discovery_links() {
if ( is_singular() ) {
$output .= '<link rel="alternate" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n";
$output .= '<link rel="alternate" type="text/xml+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink(), 'xml' ) ) . '" />' . "\n";
if ( class_exists( 'SimpleXMLElement' ) ) {
$output .= '<link rel="alternate" type="text/xml+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink(), 'xml' ) ) . '" />' . "\n";
}
}
/**

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.4-alpha-35353';
$wp_version = '4.4-alpha-35354';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.