WordPress.org

Make WordPress Core

Ticket #11636: html_entity_decode.diff

File html_entity_decode.diff, 4.6 KB (added by nacin, 3 years ago)
  • blogware.php

     
    2929                echo '</div>'; 
    3030        } 
    3131 
    32         function unhtmlentities($string) { // From php.net for < 4.3 compat 
    33                 $trans_tbl = get_html_translation_table(HTML_ENTITIES); 
    34                 $trans_tbl = array_flip($trans_tbl); 
    35                 return strtr($string, $trans_tbl); 
    36         } 
    37  
    3832        function greet() { 
    3933                echo '<div class="narrow">'; 
    4034                echo '<p>'.__('Howdy! This importer allows you to extract posts from Blogware XML export file into your blog.  Pick a Blogware file to upload and click Import.').'</p>'; 
     
    7872 
    7973                        $cat_index = 0; 
    8074                        foreach ($categories as $category) { 
    81                                 $categories[$cat_index] = $wpdb->escape($this->unhtmlentities($category)); 
     75                                $categories[$cat_index] = $wpdb->escape( html_entity_decode($category) ); 
    8276                                $cat_index++; 
    8377                        } 
    8478 
    8579                        if(strcasecmp($post_type, "photo") === 0) { 
    8680                                preg_match('|<sizedPhotoUrl>(.*?)</sizedPhotoUrl>|is', $post, $post_content); 
    8781                                $post_content = '<img src="'.trim($post_content[1]).'" />'; 
    88                                 $post_content = $this->unhtmlentities($post_content); 
     82                                $post_content = html_entity_decode( $post_content ); 
    8983                        } else { 
    9084                                preg_match('|<body>(.*?)</body>|is', $post, $post_content); 
    9185                                $post_content = str_replace(array ('<![CDATA[', ']]>'), '', trim($post_content[1])); 
    92                                 $post_content = $this->unhtmlentities($post_content); 
     86                                $post_content = html_entity_decode( $post_content ); 
    9387                        } 
    9488 
    9589                        // Clean up content 
     
    130124                                foreach ($comments as $comment) { 
    131125                                        preg_match('|<body>(.*?)</body>|is', $comment, $comment_content); 
    132126                                        $comment_content = str_replace(array ('<![CDATA[', ']]>'), '', trim($comment_content[1])); 
    133                                         $comment_content = $this->unhtmlentities($comment_content); 
     127                                        $comment_content = html_entity_decode( $comment_content ); 
    134128 
    135129                                        // Clean up content 
    136130                                        $comment_content = preg_replace_callback('|<(/?[A-Z]+)|', array( &$this, '_normalize_tag' ), $comment_content); 
  • rss.php

     
    3030                echo '</div>'; 
    3131        } 
    3232 
    33         function unhtmlentities($string) { // From php.net for < 4.3 compat 
    34                 $trans_tbl = get_html_translation_table(HTML_ENTITIES); 
    35                 $trans_tbl = array_flip($trans_tbl); 
    36                 return strtr($string, $trans_tbl); 
    37         } 
    38  
    3933        function greet() { 
    4034                echo '<div class="narrow">'; 
    4135                echo '<p>'.__('Howdy! This importer allows you to extract posts from an RSS 2.0 file into your blog. This is useful if you want to import your posts from a system that is not handled by a custom import tool. Pick an RSS file to upload and click Import.').'</p>'; 
     
    8781 
    8882                        $cat_index = 0; 
    8983                        foreach ($categories as $category) { 
    90                                 $categories[$cat_index] = $wpdb->escape($this->unhtmlentities($category)); 
     84                                $categories[$cat_index] = $wpdb->escape( html_entity_decode( $category ) ); 
    9185                                $cat_index++; 
    9286                        } 
    9387 
     
    10397                        if (!$post_content) { 
    10498                                // This is for feeds that put content in description 
    10599                                preg_match('|<description>(.*?)</description>|is', $post, $post_content); 
    106                                 $post_content = $wpdb->escape($this->unhtmlentities(trim($post_content[1]))); 
     100                                $post_content = $wpdb->escape( html_entity_decode( trim( $post_content[1] ) ) ); 
    107101                        } 
    108102 
    109103                        // Clean up content 
  • wordpress.php

     
    4343                echo '</div>'; 
    4444        } 
    4545 
    46         function unhtmlentities($string) { // From php.net for < 4.3 compat 
    47                 $trans_tbl = get_html_translation_table(HTML_ENTITIES); 
    48                 $trans_tbl = array_flip($trans_tbl); 
    49                 return strtr($string, $trans_tbl); 
    50         } 
    51  
    5246        function greet() { 
    5347                echo '<div class="narrow">'; 
    5448                echo '<p>'.__('Howdy! Upload your WordPress eXtended RSS (WXR) file and we&#8217;ll import the posts, pages, comments, custom fields, categories, and tags into this blog.').'</p>'; 
     
    450444 
    451445                $tag_index = 0; 
    452446                foreach ($tags as $tag) { 
    453                         $tags[$tag_index] = $wpdb->escape($this->unhtmlentities(str_replace(array ('<![CDATA[', ']]>'), '', $tag))); 
     447                        $tags[$tag_index] = $wpdb->escape( html_entity_decode( str_replace(array( '<![CDATA[', ']]>' ), '', $tag ) ) ); 
    454448                        $tag_index++; 
    455449                } 
    456450 
     
    459453 
    460454                $cat_index = 0; 
    461455                foreach ($categories as $category) { 
    462                         $categories[$cat_index] = $wpdb->escape($this->unhtmlentities(str_replace(array ('<![CDATA[', ']]>'), '', $category))); 
     456                        $categories[$cat_index] = $wpdb->escape( html_entity_decode( str_replace( array( '<![CDATA[', ']]>' ), '', $category ) ) ); 
    463457                        $cat_index++; 
    464458                } 
    465459