Make WordPress Core

Opened 7 years ago

Last modified 6 years ago

#43100 new defect (bug)

Unexpected results from wpautop

Reported by: pross's profile pross Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: General Keywords:
Focuses: Cc:

Description

An empty paragraph will result in invalid HTML

To reproduce using default theme add echo wpautop( '<p></p>' ); into a template file.

Expected result <p></p>

Actual result </p>

Change History (4)

#1 @justinbusa
7 years ago

It looks like this happens in reverse for paragraph tags that have a style attribute. For example, this...

echo wpautop( '<p style="text-align:center;"></p>' );

will output... <p style="text-align:center;"> with no closing tag.

#2 @pross
7 years ago

Tested the bug as far back as WP 2.8, couldn't get anything earlier working in MAMP.

#3 @wiselyfoolish
7 years ago

yup this affects empty paragraphs only.

Current workaround solution is to strip empty paragraph tags from the text before running it through wpautop()

Example:

<?php
$text = '<p>First paragraph</p><p></p><p>Second Actual Paragraph</p>';
$text = preg_replace('@<p.*?></p>@', '', $text);
$text = wpautop($text);
Version 0, edited 7 years ago by wiselyfoolish (next)

#4 @pento
6 years ago

  • Version trunk deleted
Note: See TracTickets for help on using tickets.