Opened 10 months ago
Last modified 4 weeks ago
#63148 new defect (bug)
wpautop() formatting function generate invalid HTML if the text end with an empty <p> tag
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Awaiting Review | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Formatting | Keywords: | has-test-info has-patch needs-unit-tests |
| 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 (6)
This ticket was mentioned in PR #8569 on WordPress/wordpress-develop by @sukhendu2002.
10 months ago
#2
- Keywords has-patch added; needs-patch removed
Trac ticket: https://core.trac.wordpress.org/ticket/63148
#4
@
8 weeks ago
- Keywords needs-unit-tests added
- Version trunk deleted
I'm reviewing this ticket in preparation for a 6.9 dry run.
I'm removing the version field, since at least this issue isn't an issue that occurred in an unreleased development branch.
Additionally, unit tests are needed to move this ticket forward.
Welcome @gillesdoge to Trac
Reproduction Report
Description
This report validates that the issue can be reproduced.
Environment
Actual Results
Supplemental Artifacts