The filter "Convert line breaks into HTML (i.e. <br> and <p>)" turns line breaks inside <li> tags into unmatched closing </p> tags

Created on 11 April 2024, about 1 year ago

When line breaks are included inside <li> tags, unmatched closing </p> tags are generated.

Reproduce steps:
1.Go to /admin/config/content/formats/full_html, Enable filter "Convert line breaks into HTML (i.e. < br > and < p >)" under section "Enabled filters"
2.Add below html to node's body field with text format "Full HTML" and save

<ul><li>Here is a list Item.</li>
<li>Here is another list item, this time containing a line break which is converted by the filter to a br tag.
This is some more text followed by two line breaks, which the filter converts to a p tag.

And now some more text.</li>
</ul>

Expect:

  • Here is a list Item.
  • Here is another list item, this time containing a line break which is converted by the filter to a br tag.
    Then some more text followed by two line breaks, which the filter converts to a p tag.

    And now some more text.

What happened instead?
We're getting an extra </p> tag as follows:

<ul>
<li>Here is a list Item.</li>
<li>Here is another list item, this time containing a line break which is converted by the filter to a br tag.<br />
Then some more text followed by two line breaks, which the filter converts to a p tag.</p>
<p>And now some more text.</li>
</ul>

Repeat the experiement with unclosed <li> tags, and two unclosed <p> tags are generated, as follows:

<ul>
<li>Here is a list Item.</p>
<li>Here is another list item, this time containing a line break which is converted by the filter to a br tag.<br />
This is some more text followed by two line breaks, which the filter converts to a p tag.</p>
<p>And now some more text.
</ul>
🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
Filter 

Last updated 1 day ago

No maintainer
Created by

🇬🇧United Kingdom John_B London (UK), Worthing (UK), Innsbruck (Tirol)

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024