Use Html Corrector on output to correct faulty markup

Created on 14 February 2022, over 2 years ago
Updated 30 March 2023, about 1 year ago

Problem/Motivation

When HTML markup content is trimmed with smart trim, it risks getting chopped off and creating hazard in the outputted markup of the page. The strip html tags option is one way to work around that, but it seems like it leads to a lot of needing exceptions and fixing. It's easier and as far as I can see without negative consequences to run the Html corrector over output so that broken markup like

<div>Her starts my teaser

is corrected to

<div>Her starts my teaser</div>

Steps to reproduce

Use smart trim with a markup field that produces markup. Also see included unit test

Proposed resolution

Use Html::normalize

✨ Feature request
Status

Needs work

Version

2.0

Component

Code

Created by

miiimooo Europe

Live updates comments and jobs are added and updated live.
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.

  • Status changed to Needs work over 1 year ago
  • Status changed to Needs review over 1 year ago
  • Status changed to RTBC over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States ultimike Florida, USA

    @miimooo - isn't your new testTruncateWordsWithHtmlCorrector() the same things as testTruncateWords()?

    I think your idea of adding '#text' => Html::normalize($output), is probably worthy, but let's proceed in a methodical way:

    1. Find and add data to truncateCharsDataProvider() that breaks the current non-Html::normalize($output) version of the module. This will demonstrate a failing test.
    2. Then, add the Html::normalize($output) bit to demonstrate that it gets the test to pass.
    3. Finally, submit a patch with both changes (the Html::normalize($output) bit and the new data in the provider).

    Make sense?

    @Anybody - I have enabled testing - thanks for the nudge.

    -mike

  • Status changed to Needs work about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States ultimike Florida, USA
Production build 0.69.0 2024