Make WordPress Core


Ignore:
Timestamp:
08/17/2015 05:35:58 PM (10 years ago)
Author:
azaozz
Message:

Fix creating of extra <br /> tags in both PHP and JS variants of wpautop(). Add PHP tests to catch similar problems in the future.
Props valendesigns, azaozz. Fixes #33377.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/formatting.php

    r33517 r33624  
    492492    }
    493493    // Change multiple <br>s into two line breaks, which will turn into paragraphs.
    494     $pee = preg_replace('|<br />\s*<br />|', "\n\n", $pee);
     494    $pee = preg_replace('|<br\s*/?>\s*<br\s*/?>|', "\n\n", $pee);
    495495
    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)';
     
    574574        // Replace newlines that shouldn't be touched with a placeholder.
    575575        $pee = preg_replace_callback('/<(script|style).*?<\/\\1>/s', '_autop_newline_preservation_helper', $pee);
     576
     577        // Normalize <br>
     578        $pee = str_replace( array( '<br>', '<br/>' ), '<br />', $pee );
    576579
    577580        // Replace any new line characters that aren't preceded by a <br /> with a <br />.
Note: See TracChangeset for help on using the changeset viewer.