Make WordPress Core

Ticket #7691: normalize-whitespace-r8812.patch

File normalize-whitespace-r8812.patch, 2.3 KB (added by tellyworth, 18 years ago)
  • wp-includes/formatting.php

     
    21312131        return '<' . $tag . $link . ' target="' . $target . '">';
    21322132}
    21332133
     2134// normalize EOL characters and strip duplicate whitespace
     2135function normalize_whitespace( $str ) {
     2136        $str  = trim($str);
     2137        $str  = str_replace("\r", "\n", $str);
     2138        $str  = preg_replace( array( '/\n+/', '/[ \t]+/' ), array( "\n", ' ' ), $str );
     2139        return $str;
     2140}
     2141
    21342142?>
  • wp-includes/pluggable.php

     
    16441644        if ( !class_exists( 'WP_Text_Diff_Renderer_Table' ) )
    16451645                require( ABSPATH . WPINC . '/wp-diff.php' );
    16461646
    1647         // Normalize whitespace
    1648         $left_string  = trim($left_string);
    1649         $right_string = trim($right_string);
    1650         $left_string  = str_replace("\r", "\n", $left_string);
    1651         $right_string = str_replace("\r", "\n", $right_string);
    1652         $left_string  = preg_replace( array( '/\n+/', '/[ \t]+/' ), array( "\n", ' ' ), $left_string );
    1653         $right_string = preg_replace( array( '/\n+/', '/[ \t]+/' ), array( "\n", ' ' ), $right_string );
     1647        $left_string  = normalize_whitespace($left_string);
     1648        $right_string = normalize_whitespace($right_string);
    16541649
    16551650        $left_lines  = split("\n", $left_string);
    16561651        $right_lines = split("\n", $right_string);
  • wp-admin/edit-form-advanced.php

     
    4545        // Detect if there exists an autosave newer than the post and if that autosave is different than the post
    4646        if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt ) > mysql2date( 'U', $post->post_modified_gmt ) ) {
    4747                foreach ( _wp_post_revision_fields() as $autosave_field => $_autosave_field ) {
    48                         if ( wp_text_diff( $autosave->$autosave_field, $post->$autosave_field ) ) {
     48                        if ( normalize_whitespace( $autosave->$autosave_field ) != normalize_whitespace( $post->$autosave_field ) ) {
    4949                                $notice = sprintf( $notices[1], get_edit_post_link( $autosave->ID ) );
    5050                                break;
    5151                        }