Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 295090

\Drupal\filter\Plugin\Filter\FilterHtmlCorrector and Html::normalize() and incorrectly "corrects" <source> tags

$
0
0

Hi,

Whenever an image is embedded in the ckeditor, an additional end tagged is added to the source code. This leads to the following W3C validation error: Error: Stray end tag source.

Source code:
<picture><source srcset="photo4.JPG?itok=hocFQ_Zy 1x" media="screen and (min-width: 20em)" type="image/jpeg"></source><img srcset="/sites/default/files/styles/focal_point_640x800/public/field-media-image/foto4.JPG?itok=hocFQ_Zy" alt="Onderzoeken 3" title="Onderzoeken 3" typeof="foaf:Image" src="photo4.JPG?itok=hocFQ_Zy"></picture>

I've dug around in the code and determined that this is added in EntityEmbedFilter of this module (entity_embed). The process function serializes the $dom object, which is what seems to add an end tag to the childnode. This happens around line 145: $result->setProcessedText(Html::serialize($dom));

I've come across a similar issue where the reporter suggested the following solution:

$altered_html = preg_replace('/<source(.*?)><\/source>/is', '<source$1 />', Html::serialize($dom));
      return new FilterProcessResult($altered_html);

Is this, or another solution, something we should apply to this module?


Viewing all articles
Browse latest Browse all 295090

Trending Articles