WordPress.org

Make WordPress Core

Ticket #3670: 3670.4.diff

File 3670.4.diff, 6.7 KB (added by mdgl, 5 years ago)

Refreshed and enhanced patch

  • wp-includes/comment.php

     
    25172517                $excerpt = apply_filters( 'the_excerpt', $post->post_excerpt );
    25182518        }
    25192519
    2520         $excerpt = str_replace(']]>', ']]>', $excerpt);
    25212520        $excerpt = wp_html_excerpt($excerpt, 252, '…');
    25222521
    25232522        /** This filter is documented in wp-includes/post-template.php */
  • wp-includes/feed-atom.php

     
    6767                <updated><?php echo get_post_modified_time('Y-m-d\TH:i:s\Z', true); ?></updated>
    6868                <published><?php echo get_post_time('Y-m-d\TH:i:s\Z', true); ?></published>
    6969                <?php the_category_rss('atom') ?>
    70                 <summary type="<?php html_type_rss(); ?>"><![CDATA[<?php the_excerpt_rss(); ?>]]></summary>
     70                <summary type="<?php html_type_rss(); ?>"><?php echo _esc_xml_cdata( get_the_excerpt_rss() ); ?></summary>
    7171<?php if ( !get_option('rss_use_excerpt') ) : ?>
    72                 <content type="<?php html_type_rss(); ?>" xml:base="<?php the_permalink_rss() ?>"><![CDATA[<?php the_content_feed('atom') ?>]]></content>
     72                <content type="<?php html_type_rss(); ?>" xml:base="<?php the_permalink_rss() ?>"><?php echo _esc_xml_cdata( get_the_content_feed( 'atom' ) ); ?></content>
    7373<?php endif; ?>
    7474        <?php atom_enclosure();
    7575        /**
  • wp-includes/feed-rdf.php

     
    6767        <dc:creator><![CDATA[<?php the_author() ?>]]></dc:creator>
    6868        <?php the_category_rss('rdf') ?>
    6969<?php if (get_option('rss_use_excerpt')) : ?>
    70         <description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
     70        <description><?php echo _esc_xml_cdata( get_the_excerpt_rss() ); ?></description>
    7171<?php else : ?>
    72         <description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
    73         <content:encoded><![CDATA[<?php the_content_feed('rdf') ?>]]></content:encoded>
     72        <description><?php echo _esc_xml_cdata( get_the_excerpt_rss() ); ?></description>
     73        <content:encoded><?php echo _esc_xml_cdata( get_the_content_feed( 'rdf' ) ); ?></content:encoded>
    7474<?php endif; ?>
    7575        <?php
    7676        /**
  • wp-includes/feed-rss.php

     
    3030<?php while (have_posts()) : the_post(); ?>
    3131        <item>
    3232                <title><?php the_title_rss() ?></title>
    33                 <description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
     33                <description><?php echo _esc_xml_cdata( get_the_excerpt_rss() ); ?></description>
    3434                <link><?php the_permalink_rss() ?></link>
    3535                <?php
    3636                /**
  • wp-includes/feed-rss2.php

     
    9090
    9191                <guid isPermaLink="false"><?php the_guid(); ?></guid>
    9292<?php if (get_option('rss_use_excerpt')) : ?>
    93                 <description><![CDATA[<?php the_excerpt_rss(); ?>]]></description>
     93                <description><?php echo _esc_xml_cdata( get_the_excerpt_rss() ); ?></description>
    9494<?php else : ?>
    95                 <description><![CDATA[<?php the_excerpt_rss(); ?>]]></description>
    96         <?php $content = get_the_content_feed('rss2'); ?>
     95                <description><?php echo _esc_xml_cdata( get_the_excerpt_rss() ); ?></description>
     96        <?php $content = get_the_content_feed( 'rss2' ); ?>
    9797        <?php if ( strlen( $content ) > 0 ) : ?>
    98                 <content:encoded><![CDATA[<?php echo $content; ?>]]></content:encoded>
     98                <content:encoded><?php echo _esc_xml_cdata( $content ); ?></content:encoded>
    9999        <?php else : ?>
    100                 <content:encoded><![CDATA[<?php the_excerpt_rss(); ?>]]></content:encoded>
     100                <content:encoded><?php echo _esc_xml_cdata( get_the_excerpt_rss() ); ?></content:encoded>
    101101        <?php endif; ?>
    102102<?php endif; ?>
    103103                <wfw:commentRss><?php echo esc_url( get_post_comments_feed_link(null, 'rss2') ); ?></wfw:commentRss>
  • wp-includes/feed.php

     
    184184
    185185        /** This filter is documented in wp-includes/post-template.php */
    186186        $content = apply_filters( 'the_content', get_the_content() );
    187         $content = str_replace(']]>', ']]&gt;', $content);
    188187        /**
    189188         * Filter the post content for use in feeds.
    190189         *
     
    209208}
    210209
    211210/**
    212  * Display the post excerpt for the feed.
     211 * Retrieve the post excerpt for the feed.
    213212 *
    214  * @since 0.71
     213 * @since x.x.x
     214 *
     215 * @return string Current post excerpt.
    215216 */
    216 function the_excerpt_rss() {
     217function get_the_excerpt_rss() {
    217218        $output = get_the_excerpt();
    218219        /**
    219220         * Filter the post excerpt for a feed.
     
    222223         *
    223224         * @param string $output The current post excerpt.
    224225         */
    225         echo apply_filters( 'the_excerpt_rss', $output );
     226        return apply_filters( 'the_excerpt_rss', $output );
    226227}
    227228
    228229/**
     230 * Display the post excerpt for the feed.
     231 *
     232 * @since 0.71
     233 */
     234function the_excerpt_rss() {
     235        echo get_the_excerpt_rss();
     236}
     237
     238/**
    229239 * Display the permalink to the post for use in feeds.
    230240 *
    231241 * @since 2.3.0
  • wp-includes/formatting.php

     
    25502550
    25512551                /** This filter is documented in wp-includes/post-template.php */
    25522552                $text = apply_filters( 'the_content', $text );
    2553                 $text = str_replace(']]>', ']]&gt;', $text);
    25542553
    25552554                /**
    25562555                 * Filter the number of words in an excerpt.
     
    40154014
    40164015        return $spaces;
    40174016}
     4017
     4018/**
     4019 * Wrap a string in CDATA tags for inclusion of non-XML content in XML.
     4020 *
     4021 * The only invalid string in CDATA is "]]>". Since adjacent CDATA sections
     4022 * are equivalent to the result of their concatenation, the preferred method
     4023 * of including "]]>" is to split it between two sections.
     4024 *
     4025 * @since x.x.x
     4026 *
     4027 * @param string $string A string which might contain non-XML content.
     4028 * @return string A CDATA block containing the supplied string.
     4029 */
     4030function _esc_xml_cdata( $string ) {
     4031        $string = str_replace( ']]>', ']]]]><![CDATA[>', $string );
     4032        return '<![CDATA[' . $string . ']]>';
     4033}
  • wp-includes/post-template.php

     
    219219         * @param string $content Content of the current post.
    220220         */
    221221        $content = apply_filters( 'the_content', $content );
    222         $content = str_replace( ']]>', ']]&gt;', $content );
    223222        echo $content;
    224223}
    225224