Make WordPress Core

Ticket #33645: 33645-4.4-expanded.patch

File 33645-4.4-expanded.patch, 3.2 KB (added by miqrogroove, 10 years ago)
  • src/wp-includes/formatting.php

     
    496496        $allblocks = '(?:table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|form|map|area|blockquote|address|math|style|p|h[1-6]|hr|fieldset|legend|section|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary)';
    497497
    498498        // Add a single line break above block-level opening tags.
    499         $pee = preg_replace('!(<' . $allblocks . '[^>]*>)!', "\n$1", $pee);
     499        $pee = preg_replace('!(<' . $allblocks . '[\s/>])!', "\n$1", $pee);
    500500
    501501        // Add a double line break below block-level closing tags.
    502502        $pee = preg_replace('!(</' . $allblocks . '>)!', "$1\n\n", $pee);
     
    596596                $pee = str_replace(array_keys($pre_tags), array_values($pre_tags), $pee);
    597597
    598598        // Restore newlines in all elements.
    599         $pee = str_replace( " <!-- wpnl --> ", "\n", $pee );
     599        if ( false !== strpos( $pee, '<!-- wpnl -->' ) ) {
     600                $pee = str_replace( array( ' <!-- wpnl --> ', '<!-- wpnl -->' ), "\n", $pee );
     601        }
    600602
    601603        return $pee;
    602604}
  • tests/phpunit/tests/formatting/Autop.php

     
    328328                        'summary',
    329329                );
    330330
     331                // Check whitespace normalization.
    331332                $content = array();
    332333
    333334                foreach ( $blocks as $block ) {
     
    335336                }
    336337
    337338                $expected = join( "\n", $content );
    338                 $content = join( "\n\n", $content ); // WS difference
     339                $input = join( "\n\n", $content ); // WS difference
    339340
    340                 $this->assertEquals( $expected, trim( wpautop( $content ) ) );
     341                $this->assertEquals( $expected, trim( wpautop( $input ) ) );
     342
     343                $input = join( "", $content ); // WS difference
     344
     345                $this->assertEquals( $expected, trim( wpautop( $input ) ) );
     346
     347                // Check whitespace addition.
     348                $content = array();
     349
     350                foreach ( $blocks as $block ) {
     351                        $content[] = "<$block/>";
     352                }
     353
     354                $expected = join( "\n", $content );
     355                $input = join( "", $content );
     356
     357                $this->assertEquals( $expected, trim( wpautop( $input ) ) );
     358
     359                // Check whitespace addition with attributes.
     360                $content = array();
     361
     362                foreach ( $blocks as $block ) {
     363                        $content[] = "<$block attr='value'>foo</$block>";
     364                }
     365
     366                $expected = join( "\n", $content );
     367                $input = join( "", $content );
     368
     369                $this->assertEquals( $expected, trim( wpautop( $input ) ) );
    341370        }
    342371
    343372        /**
     
    420449                                "Hello <!-- a\nhref='world' -->",
    421450                                "<p>Hello <!-- a\nhref='world' --></p>\n",
    422451                        ),
     452                        array(
     453                                "Hello <!-- <object>\n<param>\n<param>\n<embed>\n</embed>\n</object>\n -->",
     454                                "<p>Hello <!-- <object>\n<param>\n<param>\n<embed>\n</embed>\n</object>\n --></p>\n",
     455                        ),
     456                        array(
     457                                "Hello <!-- <object>\n<param/>\n<param/>\n<embed>\n</embed>\n</object>\n -->",
     458                                "<p>Hello <!-- <object>\n<param/>\n<param/>\n<embed>\n</embed>\n</object>\n --></p>\n",
     459                        ),
    423460/* Block elements inside comments will fail this test in all versions, it's not a regression.
    424461                        array(
    425462                                "Hello <!-- <hr> a\nhref='world' -->",