Feeds: Ensure that enclosures produce valid XML.
Metadata that is stored on newlines has the possibility of missing values, so rather then coercing values, we can check for them and then implicity set the values. Fixes #33591. Props jonnybot, stevenkword, vtieu, birgire, SergeyBiryukov, davidbaumwald, rebasaurus, whyisjake. Built from https://develop.svn.wordpress.org/trunk@48429 git-svn-id: http://core.svn.wordpress.org/trunk@48198 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
a6fed0173d
commit
f06e883d01
|
@ -519,6 +519,35 @@ function atom_enclosure() {
|
|||
if ( 'enclosure' === $key ) {
|
||||
foreach ( (array) $val as $enc ) {
|
||||
$enclosure = explode( "\n", $enc );
|
||||
|
||||
$url = '';
|
||||
$type = '';
|
||||
$length = 0;
|
||||
|
||||
$mimes = get_allowed_mime_types();
|
||||
|
||||
// Parse url
|
||||
if ( isset( $enclosure[0] ) && is_string( $enclosure[0] ) ) {
|
||||
$url = trim( $enclosure[0] );
|
||||
}
|
||||
|
||||
// Parse length and type
|
||||
foreach ( range( 1, 2 ) as $i ) {
|
||||
if ( isset( $enclosure[ $i ] ) ) {
|
||||
if ( is_numeric( $enclosure[ $i ] ) ) {
|
||||
$length = trim( $enclosure[ $i ] );
|
||||
} elseif ( in_array( $enclosure[ $i ], $mimes ) ) {
|
||||
$type = trim( $enclosure[ $i ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$html_link_tag = sprintf(
|
||||
"<link href=\"%s\" rel=\"enclosure\" length=\"%d\" type=\"%s\" />\n",
|
||||
esc_url( $url ),
|
||||
esc_attr( $length ),
|
||||
esc_attr( $type )
|
||||
);
|
||||
/**
|
||||
* Filters the atom enclosure HTML link tag for the current post.
|
||||
*
|
||||
|
@ -526,7 +555,7 @@ function atom_enclosure() {
|
|||
*
|
||||
* @param string $html_link_tag The HTML link tag with a URI and other attributes.
|
||||
*/
|
||||
echo apply_filters( 'atom_enclosure', '<link href="' . esc_url( trim( $enclosure[0] ) ) . '" rel="enclosure" length="' . absint( trim( $enclosure[1] ) ) . '" type="' . esc_attr( trim( $enclosure[2] ) ) . '" />' . "\n" );
|
||||
echo apply_filters( 'atom_enclosure', $html_link_tag );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.5-beta1-48428';
|
||||
$wp_version = '5.5-beta1-48429';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue