Ticket #7563: html_entity_decode.patch

File html_entity_decode.patch, 5.3 KB (added by adferguson, 4 years ago)

Actual patch to change all html_entity_decode calls to respect blog charset

  • wp-admin/import/blogger.php

    diff -Nur wordpress-2.7.1/wp-admin/import/blogger.php wordpress-devel/wp-admin/import/blogger.php
    old new  
    437437                                if ( count( $matches[1] ) ) 
    438438                                        foreach ( $matches[1] as $match ) 
    439439                                                if ( preg_match('/rel=.previous./', $match) ) 
    440                                                         $query = html_entity_decode( preg_replace('/^.*href=[\'"].*\?(.+)[\'"].*$/', '$1', $match) ); 
     440                                                        $query = html_entity_decode( preg_replace('/^.*href=[\'"].*\?(.+)[\'"].*$/', '$1', $match), ENT_COMPAT, get_option('blog_charset') ); 
    441441 
    442442                                if ( $query ) { 
    443443                                        parse_str($query, $q); 
     
    495495                                if ( count( $matches[1] ) ) 
    496496                                        foreach ( $matches[1] as $match ) 
    497497                                                if ( preg_match('/rel=.previous./', $match) ) 
    498                                                         $query = html_entity_decode( preg_replace('/^.*href=[\'"].*\?(.+)[\'"].*$/', '$1', $match) ); 
     498                                                        $query = html_entity_decode( preg_replace('/^.*href=[\'"].*\?(.+)[\'"].*$/', '$1', $match), ENT_COMPAT, get_option('blog_charset') ); 
    499499 
    500500                                parse_str($query, $q); 
    501501 
     
    545545                } 
    546546 
    547547                $post_date    = $this->convert_date( $entry->published ); 
    548                 $post_content = trim( addslashes( $this->no_apos( html_entity_decode( $entry->content ) ) ) ); 
     548                $post_content = trim( addslashes( $this->no_apos( html_entity_decode( $entry->content, ENT_COMPAT, get_option('blog_charset') ) ) ) ); 
    549549                $post_title   = trim( addslashes( $this->no_apos( $this->min_whitespace( $entry->title ) ) ) ); 
    550550                $post_status  = isset( $entry->draft ) ? 'draft' : 'publish'; 
    551551 
     
    600600                $comment_author  = addslashes( $this->no_apos( strip_tags( (string) $matches[1] ) ) ); 
    601601                $comment_author_url = addslashes( $this->no_apos( strip_tags( (string) $matches[2] ) ) ); 
    602602                $comment_date    = $this->convert_date( $entry->updated ); 
    603                 $comment_content = addslashes( $this->no_apos( html_entity_decode( $entry->content ) ) ); 
     603                $comment_content = addslashes( $this->no_apos( html_entity_decode( $entry->content, ENT_COMPAT, get_option('blog_charset') ) ) ); 
    604604 
    605605                // Clean up content 
    606606                $comment_content = preg_replace_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[1]);'), $comment_content); 
  • wp-admin/includes/dashboard.php

    diff -Nur wordpress-2.7.1/wp-admin/includes/dashboard.php wordpress-devel/wp-admin/includes/dashboard.php
    old new  
    731731                        $title = $item['title']; 
    732732                $title = wp_specialchars( $title ); 
    733733 
    734                 $description = wp_specialchars( strip_tags(html_entity_decode($item['description'], ENT_QUOTES)) ); 
     734                $description = wp_specialchars( strip_tags(html_entity_decode($item['description'], ENT_QUOTES, get_option('blog_charset'))) ); 
    735735 
    736736                list($link, $frag) = explode( '#', $item['link'] ); 
    737737 
  • wp-includes/feed.php

    diff -Nur wordpress-2.7.1/wp-includes/feed.php wordpress-devel/wp-includes/feed.php
    old new  
    340340                elseif ( 'atom' == $type ) 
    341341                        $the_list .= sprintf( '<category scheme="%1$s" term="%2$s" />', attribute_escape( apply_filters( 'get_bloginfo_rss', get_bloginfo( 'url' ) ) ), attribute_escape( $cat_name ) ); 
    342342                else 
    343                         $the_list .= "\n\t\t<category><![CDATA[" . html_entity_decode( $cat_name ) . "]]></category>\n"; 
     343                        $the_list .= "\n\t\t<category><![CDATA[" . html_entity_decode( $cat_name, ENT_COMPAT, get_option('blog_charset') ) . "]]></category>\n"; 
    344344        } 
    345345 
    346346        return apply_filters('the_category_rss', $the_list, $type); 
  • wp-includes/widgets.php

    diff -Nur wordpress-2.7.1/wp-includes/widgets.php wordpress-devel/wp-includes/widgets.php
    old new  
    15081508        $link = clean_url(strip_tags($rss->channel['link'])); 
    15091509        while ( strstr($link, 'http') != $link ) 
    15101510                $link = substr($link, 1); 
    1511         $desc = attribute_escape(strip_tags(html_entity_decode($rss->channel['description'], ENT_QUOTES))); 
     1511        $desc = attribute_escape(strip_tags(html_entity_decode($rss->channel['description'], ENT_QUOTES, get_option('blog_charset')))); 
    15121512        $title = $options[$number]['title']; 
    15131513        if ( empty($title) ) 
    15141514                $title = htmlentities(strip_tags($rss->channel['title'])); 
     
    15771577                                $title = __('Untitled'); 
    15781578                        $desc = ''; 
    15791579                        if ( isset( $item['description'] ) && is_string( $item['description'] ) ) 
    1580                                 $desc = str_replace(array("\n", "\r"), ' ', attribute_escape(strip_tags(html_entity_decode($item['description'], ENT_QUOTES)))); 
     1580                                $desc = str_replace(array("\n", "\r"), ' ', attribute_escape(strip_tags(html_entity_decode($item['description'], ENT_QUOTES, get_option('blog_charset'))))); 
    15811581                        elseif ( isset( $item['summary'] ) && is_string( $item['summary'] ) ) 
    1582                                 $desc = str_replace(array("\n", "\r"), ' ', attribute_escape(strip_tags(html_entity_decode($item['summary'], ENT_QUOTES)))); 
     1582                                $desc = str_replace(array("\n", "\r"), ' ', attribute_escape(strip_tags(html_entity_decode($item['summary'], ENT_QUOTES, get_option('blog_charset'))))); 
    15831583                        if ( 360 < strlen( $desc ) ) 
    15841584                                $desc = wp_html_excerpt( $desc, 360 ) . ' [&hellip;]'; 
    15851585                        $summary = $desc;