Ticket #1261: 1261-final.patch

File 1261-final.patch, 4.0 KB (added by GautamGupta, 2 years ago)

Final patch to fix this ticket

  • bb-includes/defaults.bb-filters.php

     
    126126 
    127127                add_filter( 'post_author', 'ent2ncr', 8 ); 
    128128                add_filter( 'post_link', 'esc_html' ); 
    129                 add_filter( 'post_text_rss', 'ent2ncr', 8 ); 
    130                 add_filter( 'post_text_rss', 'esc_html' ); 
     129                add_filter( 'post_text', 'ent2ncr', 8 ); 
     130                add_filter( 'post_text', 'bb_convert_chars' ); 
    131131        } 
    132132} 
    133133add_action( 'bb_init', 'bb_filter_feed_content' ); 
  • bb-includes/functions.bb-formatting.php

     
    329329 
    330330        return $time; 
    331331} 
     332 
     333/** 
     334 * Converts a number of characters from a string. 
     335 * 
     336 * Metadata tags <<title>> and <<category>> are removed, <<br>> and <<hr>> are 
     337 * converted into correct XHTML and Unicode characters are converted to the 
     338 * valid range. 
     339 * 
     340 * @param string $content String of characters to be converted. 
     341 *  
     342 * @return string Converted string. 
     343 */ 
     344function bb_convert_chars( $content ) { 
     345        // Translation of invalid Unicode references range to valid range 
     346        $wp_htmltranswinuni = array( 
     347        '&#128;' => '&#8364;', // the Euro sign 
     348        '&#129;' => '', 
     349        '&#130;' => '&#8218;', // these are Windows CP1252 specific characters 
     350        '&#131;' => '&#402;',  // they would look weird on non-Windows browsers 
     351        '&#132;' => '&#8222;', 
     352        '&#133;' => '&#8230;', 
     353        '&#134;' => '&#8224;', 
     354        '&#135;' => '&#8225;', 
     355        '&#136;' => '&#710;', 
     356        '&#137;' => '&#8240;', 
     357        '&#138;' => '&#352;', 
     358        '&#139;' => '&#8249;', 
     359        '&#140;' => '&#338;', 
     360        '&#141;' => '', 
     361        '&#142;' => '&#382;', 
     362        '&#143;' => '', 
     363        '&#144;' => '', 
     364        '&#145;' => '&#8216;', 
     365        '&#146;' => '&#8217;', 
     366        '&#147;' => '&#8220;', 
     367        '&#148;' => '&#8221;', 
     368        '&#149;' => '&#8226;', 
     369        '&#150;' => '&#8211;', 
     370        '&#151;' => '&#8212;', 
     371        '&#152;' => '&#732;', 
     372        '&#153;' => '&#8482;', 
     373        '&#154;' => '&#353;', 
     374        '&#155;' => '&#8250;', 
     375        '&#156;' => '&#339;', 
     376        '&#157;' => '', 
     377        '&#158;' => '', 
     378        '&#159;' => '&#376;' 
     379        ); 
     380 
     381        // Remove metadata tags 
     382        $content = preg_replace( '/<title>(.+?)<\/title>/', '', $content ); 
     383        $content = preg_replace( '/<category>(.+?)<\/category>/', '', $content ); 
     384 
     385        // Converts lone & characters into &#38; (a.k.a. &amp;) 
     386        $content = preg_replace( '/&([^#])(?![a-z1-4]{1,8};)/i', '&#038;$1', $content ); 
     387 
     388        // Fix Word pasting 
     389        $content = strtr( $content, $wp_htmltranswinuni ); 
     390 
     391        // Just a little XHTML help 
     392        $content = str_replace( '<br>', '<br />', $content ); 
     393        $content = str_replace( '<hr>', '<hr />', $content ); 
     394 
     395        return $content; 
     396} 
     397 No newline at end of file 
  • bb-includes/functions.bb-template.php

     
    17851785        } 
    17861786} 
    17871787 
    1788 function post_text_rss( $post_id = 0 ) { 
    1789         echo apply_filters( 'post_text_rss', get_post_text( $post_id ), get_post_id( $post_id ) ); 
    1790 } 
    1791  
    17921788function post_text( $post_id = 0 ) { 
    17931789        echo apply_filters( 'post_text', get_post_text( $post_id ), get_post_id( $post_id ) ); 
    17941790} 
  • bb-templates/kakumei/rss2.php

     
    2626                        <pubDate><?php bb_post_time( 'D, d M Y H:i:s +0000', array( 'localize' => false ) ); ?></pubDate> 
    2727                        <dc:creator><?php post_author(); ?></dc:creator> 
    2828                        <guid isPermaLink="false"><?php post_id(); ?>@<?php bb_uri(); ?></guid> 
    29                         <description><?php post_text_rss(); ?></description> 
    30                         <content:encoded><![CDATA[<?php post_text_rss(); ?>]]></content:encoded> 
     29                        <description><![CDATA[<?php post_text(); ?>]]></description> 
    3130                        <?php do_action( 'bb_rss2_item' ); ?> 
    3231                </item> 
    3332<?php endforeach; ?>