WordPress.org

Make WordPress Core

Ticket #5998: comment.php.diff

File comment.php.diff, 1.1 KB (added by dwright, 10 years ago)

wp-includes/comment.php.diff try php xml parser load, bails on non valid utf8

  • wp-includes/comment.php

     
    11211121 * @return int The ID of the comment after adding.
    11221122 */
    11231123function wp_new_comment( $commentdata ) {
     1124    if ( get_bloginfo('html_type') == 'application/xhtml+xml'
     1125         && get_bloginfo('charset') == 'UTF-8' ) {
     1126        if ( $xml_parser = xml_parser_create('UTF-8') ){
     1127            $fake_xml_wrap = '<pre>' . $commentdata['comment_content'] . '</pre>';
     1128            if (!xml_parse($xml_parser, $fake_xml_wrap)) {
     1129                $err = sprintf('XML error: %s at line %d column %d',
     1130                         xml_error_string(xml_get_error_code($xml_parser)),
     1131                         xml_get_current_line_number($xml_parser),
     1132                         xml_get_current_column_number($xml_parser));
     1133                wp_die( __($err) );
     1134            }
     1135        }
     1136        xml_parser_free($xml_parser);
     1137    }
    11241138        $commentdata = apply_filters('preprocess_comment', $commentdata);
    11251139
    11261140        $commentdata['comment_post_ID'] = (int) $commentdata['comment_post_ID'];