redactor icon indicating copy to clipboard operation
redactor copied to clipboard

Empty links with href but no label are not removed by empty tags cleanup

Open jamesmacwhite opened this issue 2 years ago • 0 comments

Description

We have found occurrences of invalid HTML in redactor fields such as this example:

<p>Some example paragraph text <a href="url/something.pdf#asset:5902:url"></a><a href="url/something.pdf#asset:5904:url"></a><a href="url/something.pdf#asset:170586:url"></a><a href="url/something.pdf#asset:192253:url">some text linked</a>.</p>

There were several empty anchor tags without a label when viewing the HTML source for the redactor field data.

It would appear that the original link has changed one or more times but the original linked href value changing left the original anchor without a label in place, while adding a correct link with the label set.

The cleanup option for empty tags only matches on <a></a> it doesn't match the case for something like <a href="url"></a>.

How the situation occurred with empty links is an interesting one, but could the cleanup regex be expanded to cover this scenario potentially?

Steps to reproduce

  1. Add an empty link with a href but no label e.g. <a href="https://www.google.co.uk"></a>
  2. Observe this will be present in the redactor field but without any indication of it's presence in the CMS when saving.

Additional info

  • Craft version: 3.7.56
  • PHP version: 8.0
  • Database driver & version: MySQL
  • Plugins & versions: Redactor 2.10.10

jamesmacwhite avatar Oct 20 '22 10:10 jamesmacwhite