Make WordPress Core

Opened 6 weeks ago

Last modified 5 weeks ago

#63148 new defect (bug)

wpautop() formatting function generate invalid HTML if the text end with an empty <p> tag

Reported by: gillesdoge's profile gillesdoge Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: trunk
Component: Formatting Keywords: has-testing-info has-patch
Focuses: Cc:

Description

It's probably my first ticket (hi there 👋 !).

When preparing a migration of an old WordPress, I was facing the following issue:

<?php

$text = "<p>test</p>
<p></p>";

var_dump(wpautop($text);
// Output: string(16) "<p>test</p></p>
// "

You may ask, but why do you need to apply wpautop() on an already formatted text?
Because some of the content needed it (paragraphs only separated by newlines) and some was already formatted with HTML and Classic Editor.

My current countermeasure is to test if the content already have <p> and don't apply wpautop().

Is this a know issue (I found nothing when searching) ?

Change History (2)

#1 @SirLouen
6 weeks ago

  • Keywords needs-patch has-testing-info added

Welcome @gillesdoge to Trac

Reproduction Report

Description

This report validates that the issue can be reproduced.

Environment

  • WordPress: 6.8-beta3-60042-src
  • PHP: 8.2.28
  • Server: nginx/1.27.4
  • Database: mysqli (Server: 8.4.4 / Client: mysqlnd 8.2.28)
  • Browser: Chrome 134.0.0.0
  • OS: Windows 10/11
  • Theme: Twenty Nineteen 3.0
  • MU Plugins: None activated
  • Plugins:
    • Hello Dolly 1.7.2
    • Test Reports 1.2.0

Actual Results

  1. ✅ Error condition occurs (reproduced).

Supplemental Artifacts

https://i.imgur.com/10qkA6o.png

Last edited 6 weeks ago by SirLouen (previous) (diff)

This ticket was mentioned in PR #8569 on WordPress/wordpress-develop by @sukhendu2002.


5 weeks ago
#2

  • Keywords has-patch added; needs-patch removed
Note: See TracTickets for help on using tickets.