Trimmed body display format can result in faulty and chopped off HTML if "Correct faulty and chopped off HTML" is not activated on the text format

Created on 27 April 2016, over 8 years ago
Updated 20 May 2024, 7 months ago

Hi,

I am getting the lots of jquery error, So It would break all the jquery functionality in that page.

Steps to reproduce the issue :

1. Set Body field format as Trimmed with limit (100 char) in Teaser mode
2. Create article node with tag in body field
for example :
<p><em>Globally myocardinate orthogonal communities through frictionless leadership skills. Completely engage client-based customer service and cross-platform human capital. Professionally generate vertical web-readiness rather than magnetic data. Distinctively target optimal infomediaries via synergistic products. Interactively develop vertical manufactured products and highly efficient niche markets.</em></p>
Add these in the body field. and save the node.
3. Then see the article node in teaser mode, you would see the jquery errors.

Before patch - italics apply to the rest of the page:

After patch - italics are correctly clipped at the end of the summary:

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
Text 

Last updated 9 days ago

Created by

🇮🇳India leopathu

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.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇧🇬Bulgaria korn3000 Burgas

    reroll Patch for 10.2.x

  • 🇳🇿New Zealand luke.stewart

    Just noting here to help future me (and others) that looks like the following awesomeness can occur - that sent me deep into the weeds.

    If you are displaying a content type using a display mode that uses a trimmed text field it can truncate html in a way that there is an open tag. In my case this was a <b> because the closing tag was after the full stop.

    This then caused a host of drupalSettings. to be undefined, and while drupalSettings existed - it was empty. so for example drupalSettings.user was undefined causing various errors in contextual links. (adding to help search indexing).

    https://drupal.stackexchange.com/questions/270863/drupalsettings-object-...
    Which when I inspected source to see if I was experiencing the same - identified that there was some invalid html.

    While I manually corrected the broken HTML I figured it wasn't great you could break the site by accidentally highlighting the space after the fullstop to close your bold text... Which lead me here.

    I applied the patch and it applied cleanly on 10.3.6 with some offsets.

    In my use case I had a View outputting nodes using a summary display mode. Before and After applying the patch I still see the broken html. I'm not clear from the above if this is supposed to fix this case or not. However updating text modes to select fix faulty and broken html resolved the above.

Production build 0.71.5 2024