Problem/Motivation

The _filter_autop() function was updated to support HTML5 block tags a long time ago, but those changes have never been ported to D7.

Proposed resolution

Only port the _filter_autop() from D8 to D7. No other fixes or improvements in this issue.

User interface changes

Broken filtered text containing HTML5 tags will be fixed.

API changes

None.

Data model changes

None.

Comments

pingwin4eg created an issue. See original summary.

pingwin4eg’s picture

Assigned: pingwin4eg » Unassigned
Status: Active » Needs review
StatusFileSize
new3.63 KB

Here's the patch.

Status: Needs review » Needs work

The last submitted patch, 2: drupal-filter_autop_D7-3005630-2.patch, failed testing. View results

pingwin4eg’s picture

StatusFileSize
new3.52 KB

Hmm, let's try the same patch created using diff.

pingwin4eg’s picture

Status: Needs work » Needs review
tr’s picture

Status: Needs review » Needs work

When you said

The _filter_autop() function was updated to support HTML5 block tags a long time ago

you didn't include a link to the issue containing the change that needs backporting.

I was able to trace that change to #900956: Update autop filter to include missing block level tags, committed in 2013:

commit e5313544bce78b8aef5ed2fbd79f08a4d6aff5dc
Author: Dries <dries@buytaert.net>
Date:   Fri Mar 8 09:12:35 2013 -0500

    Issue #900956 by quicksketch, sun: update autop filter to include missing block level tags.

diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module
index b827b4fcb1..725d9312b7 100644
--- a/core/modules/filter/filter.module
+++ b/core/modules/filter/filter.module
@@ -1688,7 +1688,7 @@ function _filter_htmlcorrector($text) {
  */
 function _filter_autop($text) {
   // All block level tags
-  $block = '(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|p|h[1-6]|hr|article|aside|details|figcaption|figure|footer|header|hgroup|menu|nav|section|summary)';
+  $block = '(?:table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|option|form|map|area|blockquote|address|math|input|p|h[1-6]|fieldset|legend|hr|article|aside|details|figcaption|figure|footer|header|hgroup|menu|nav|section|summary)';
 
   // Split at opening and closing PRE, SCRIPT, STYLE, OBJECT, IFRAME tags
   // and comments. We don't apply any processing to the contents of these tags
@@ -1740,7 +1740,7 @@ function _filter_autop($text) {
       $chunk = preg_replace('!(</?' . $block . '[^>]*>)\s*</p>!', "$1", $chunk);
       $chunk = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $chunk); // make line breaks
       $chunk = preg_replace('!(</?' . $block . '[^>]*>)\s*<br />!', "$1", $chunk);
-      $chunk = preg_replace('!<br />(\s*</?(?:p|li|div|th|pre|td|ul|ol)>)!', '$1', $chunk);
+      $chunk = preg_replace('!<br />(\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)>)!', '$1', $chunk);
       $chunk = preg_replace('/&([^#])(?![A-Za-z0-9]{1,8};)/', '&amp;$1', $chunk);
     }
     $output .= $chunk;

The problem with your patch is that you are making out-of-scope coding standards changes in your backport, in addition to changing just the two lines that were modified in #900956: Update autop filter to include missing block level tags. Plus, you coding standards changes are not proper (no upper case, no line terminator on inline comments).

As a minimum, this patch needs a re-roll to remove those out-of-scope changes. That will make the patch much easier to review properly.

tr’s picture

pingwin4eg’s picture

Oh, those coding standards changes are definitely not mine)))

As far as I remember, the patch was a pure diff of the _filter_autop() between D7 and D8 at the time. And this issue title and the proposed resolution are evidence of that.

That's why I didn't include links to any specific issues. There are few of them. HTML5 block tags were just one example of what was missing in D7.

And the mess with comments is still there in the HEAD.

Status: Needs work » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.