Make WordPress Core

Ticket #9437: 9437.2.diff

File 9437.2.diff, 1.9 KB (added by jared_smith, 9 years ago)

Updated patch with code changes and unit tests

  • src/wp-includes/formatting.php

     
    541541        // Optionally insert line breaks.
    542542        if ( $br ) {
    543543                // Replace newlines that shouldn't be touched with a placeholder.
    544                 $pee = preg_replace_callback('/<(script|style).*?<\/\\1>/s', '_autop_newline_preservation_helper', $pee);
     544                $pee = preg_replace_callback('/<(script|style|svg).*?<\/\\1>/s', '_autop_newline_preservation_helper', $pee);
    545545
    546546                // Normalize <br>
    547547                $pee = str_replace( array( '<br>', '<br/>' ), '<br />', $pee );
     
    47914791                $short_url = substr( $short_url, 0, $length - 3 ) . '&hellip;';
    47924792        }
    47934793        return $short_url;
    4794 }
    4795  No newline at end of file
     4794}
  • tests/phpunit/tests/formatting/Autop.php

     
    524524                $this->assertEquals( $expected, trim( wpautop( $content ) ) );
    525525        }
    526526
     527        /**
     528         * wpautop() should ignore inline SVG graphics
     529         *
     530         * @ticket 9437
     531         */
     532        function test_that_wpautop_ignores_inline_svgs() {
     533                $content=
     534                        '<svg xmlns="http://www.w3.org/2000/svg">
     535                                <circle cx="50" cy="50" r="30" fill="blue">
     536                                        <animateTransform attributeName="transform" type="scale" to="1.5" dur="2s" fill="freeze"/>
     537                                </circle>
     538                        </svg>';
     539                $expected='<p>'.$content.'</p>';
     540                $this->assertEquals( $expected, trim( wpautop( $content ) ) );
     541        }
     542
     543        /**
     544         * wpautop() should ignore inline scripts
     545         *
     546         * @ticket 9437
     547         */
     548        function test_that_wpautop_ignores_inline_scripts() {
     549                $content=
     550                        '<script type="text/javascript">
     551
     552                                 var dummy = 1;
     553                        </script>';
     554                $expected='<p>'.$content.'</p>';
     555                $this->assertEquals( $expected, trim( wpautop( $content ) ) );
     556        }
     557
    527558}