In a vanilla drupal 7.56 or 7.x-dev I create a basic page with a title and the following content where I also select Full HTML:

<svg height="333" width="333" xmlns="http://www.w3.org/2000/svg"><line style="stroke:rgb(255,0,0);stroke-width:3" x1="0" x2="333" y1="0" y2="333"></line></svg>

The front end rendering of this is broken because a <br /> is inserted just before <line:

<svg height="333" width="333" xmlns="http://www.w3.org/2000/svg"><br /><line style="stroke:rgb(255,0,0);stroke-width:3" x1="0" x2="333" y1="0" y2="333"></line></svg>

This is caused by Convert line breaks into HTML (i.e. <br> and <p>) (default checked) in admin/config/content/formats/full_html.

The code that does this is in filter.module around 1750:

$chunk = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $chunk); // make line breaks

In order to get this to work I now have to deselect the "Convert line breaks into HTML". Note that in my content there aren't any line breaks. The whole content is just an one-liner.

Comments

ioannis.cherouvim created an issue. See original summary.

ioannis.cherouvim’s picture

Issue summary: View changes
ioannis.cherouvim’s picture

Issue summary: View changes
ioannis.cherouvim’s picture

Issue summary: View changes
ioannis.cherouvim’s picture

Issue summary: View changes
ioannis.cherouvim’s picture

Issue summary: View changes
karivolas’s picture

The <svg> tag is not considered a block tag, so the filter module will add a \n at the end, which will then be replaced by a <br />.

The svg tag should be added in the first preg_split at line 1707, where we set a list of tags that we don't want to process.

karivolas’s picture

Assigned: Unassigned » karivolas
Status: Active » Needs review
karivolas’s picture

Assigned: karivolas » Unassigned
akz’s picture

I confirm that this is a valid problem and valid patch fix. Please include in next core update.

Webbeh’s picture

Status: Needs review » Reviewed & tested by the community

Reviewed via #10, although some additional confirmation would help validate the status change.

meltoner’s picture

I confirm this issue and the patch fixes the problem. Please include in next core update.

poker10’s picture

StatusFileSize
new778 bytes
new1.59 KB

Thanks for working on this! Patch #7 looks great and it is the same change as is currently in D9, see: https://git.drupalcode.org/project/drupal/-/blob/9.5.x/core/modules/filter/filter.module#L693

I have added the SVG to the current filter tests (the same is in D9), so we can demonstrate the failure.

Manual testing also confirms that the patch is working.

The last submitted patch, 13: 2925487-13_test-only.patch, failed testing. View results

  • mcdruid committed 2ee8c2a on 7.x
    Issue #2925487 by poker10, karivolas, ioannis.cherouvim: svg element is...
mcdruid’s picture

Status: Reviewed & tested by the community » Fixed

Thanks everyone!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.