From b5237ed71f2172094b99cbc3b34b05ba09196a94 Mon Sep 17 00:00:00 2001 From: Santeri Hurnanen Date: Tue, 14 May 2024 11:11:21 +0300 Subject: [PATCH 1/4] UHF-9980: Add patch --- ...3083786-duplicate-br-tags-2024-05-13.patch | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 patches/3083786-duplicate-br-tags-2024-05-13.patch diff --git a/patches/3083786-duplicate-br-tags-2024-05-13.patch b/patches/3083786-duplicate-br-tags-2024-05-13.patch new file mode 100644 index 000000000..6f89ab054 --- /dev/null +++ b/patches/3083786-duplicate-br-tags-2024-05-13.patch @@ -0,0 +1,43 @@ +diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module +index c6cae99e5a..124668de0d 100644 +--- a/core/modules/filter/filter.module ++++ b/core/modules/filter/filter.module +@@ -755,9 +755,15 @@ function _filter_autop($text) { + $chunk = preg_replace('!

\s*(]*>)!', "$1", $chunk); + $chunk = preg_replace('!(]*>)\s*

!', "$1", $chunk); + // make line breaks +- $chunk = preg_replace('|(?)\s*\n|', "
\n", $chunk); +- $chunk = preg_replace('!(]*>)\s*
!', "$1", $chunk); +- $chunk = preg_replace('!
(\s*)!', '$1', $chunk); ++ $chunk = preg_replace_callback('|(]*>)?\s*\n|', function ($matches) { ++ if (isset($matches[1])) { ++ return $matches[1] . "\n"; ++ } ++ ++ return "
\n"; ++ }, $chunk); ++ $chunk = preg_replace('!(]*>)\s*]*/>!', "$1", $chunk); ++ $chunk = preg_replace('!]*>(\s*)!', '$1', $chunk); + $chunk = preg_replace('/&([^#])(?![A-Za-z0-9]{1,8};)/', '&$1', $chunk); + } + $output .= $chunk; +diff --git a/core/modules/filter/tests/src/Kernel/FilterKernelTest.php b/core/modules/filter/tests/src/Kernel/FilterKernelTest.php +index cfc8cdb503..0cdef41699 100644 +--- a/core/modules/filter/tests/src/Kernel/FilterKernelTest.php ++++ b/core/modules/filter/tests/src/Kernel/FilterKernelTest.php +@@ -469,6 +469,15 @@ class FilterKernelTest extends KernelTestBase { + '' => [ + '

' => FALSE, + ], ++ // Bug 3083786, duplicate br tags after a line ending in a break tag that ++ // doesn't exactly match
++ 'aaa
++ bbb
++ ddd
' => [ ++ "

aaa
\n" => TRUE, ++ "bbb
\n" => TRUE, ++ "ddd

" => TRUE, ++ ], + ]; + // cSpell:enable + $this->assertFilteredString($filter, $tests); From ee6fd3bfd18eeaa1210698df39d54577e250fe65 Mon Sep 17 00:00:00 2001 From: Santeri Hurnanen Date: Mon, 13 May 2024 20:07:27 +0300 Subject: [PATCH 2/4] UHF-9980: Replace patch --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index ba5d149be..a7bdd48a4 100644 --- a/composer.json +++ b/composer.json @@ -87,7 +87,7 @@ "[#UHF-7008] Admin toolbar and contextual links should always be rendered in the admin language (https://www.drupal.org/project/drupal/issues/2313309)": "https://www.drupal.org/files/issues/2023-12-19/2313309-179.patch", "[#UHF-9388] Process translation config files for custom modules (https://www.drupal.org/i/2845437)": "https://www.drupal.org/files/issues/2023-10-16/2845437-61.patch", "[#UHF-9690] Allow updating lists when switching from allowed values to allowed values function (https://www.drupal.org/i/2873353)": "https://www.drupal.org/files/issues/2021-05-18/allow-allowed-values-function-update-D9-2873353_1.patch", - "[#UHF-9952] Convert line breaks into HTML filter generates duplicate br tags after a line ending (https://www.drupal.org/i/3083786)": "https://www.drupal.org/files/issues/2024-02-29/3083786-br-generates-duplicate-tags.patch" + "[#UHF-9952, #UHF-9980] Duplicate
tags (https://www.drupal.org/i/3083786)": "https://raw.githubusercontent.com/City-of-Helsinki/drupal-helfi-platform-config/UHF-9980-br-tags/patches/3083786-duplicate-br-tags-2024-05-13.patch" }, "drupal/default_content": { "https://www.drupal.org/project/default_content/issues/2640734#comment-14638943": "https://raw.githubusercontent.com/City-of-Helsinki/drupal-helfi-platform-config/main/patches/default_content_2.0.0-alpha2-2640734_manual_imports-e164a354.patch" From 5ff07b3a6cc8f16dcd655a5c7e370ae73d43f50f Mon Sep 17 00:00:00 2001 From: Santeri Hurnanen Date: Tue, 14 May 2024 13:01:11 +0300 Subject: [PATCH 3/4] UHF-9980: Use patch from drupal.org --- composer.json | 2 +- ...3083786-duplicate-br-tags-2024-05-13.patch | 43 ------------------- 2 files changed, 1 insertion(+), 44 deletions(-) delete mode 100644 patches/3083786-duplicate-br-tags-2024-05-13.patch diff --git a/composer.json b/composer.json index a7bdd48a4..fa593a7d1 100644 --- a/composer.json +++ b/composer.json @@ -87,7 +87,7 @@ "[#UHF-7008] Admin toolbar and contextual links should always be rendered in the admin language (https://www.drupal.org/project/drupal/issues/2313309)": "https://www.drupal.org/files/issues/2023-12-19/2313309-179.patch", "[#UHF-9388] Process translation config files for custom modules (https://www.drupal.org/i/2845437)": "https://www.drupal.org/files/issues/2023-10-16/2845437-61.patch", "[#UHF-9690] Allow updating lists when switching from allowed values to allowed values function (https://www.drupal.org/i/2873353)": "https://www.drupal.org/files/issues/2021-05-18/allow-allowed-values-function-update-D9-2873353_1.patch", - "[#UHF-9952, #UHF-9980] Duplicate
tags (https://www.drupal.org/i/3083786)": "https://raw.githubusercontent.com/City-of-Helsinki/drupal-helfi-platform-config/UHF-9980-br-tags/patches/3083786-duplicate-br-tags-2024-05-13.patch" + "[#UHF-9952, #UHF-9980] Duplicate
tags (https://www.drupal.org/i/3083786)": "https://www.drupal.org/files/issues/2024-05-14/3083786-duplicate-br-tags-2024-05-14.patch" }, "drupal/default_content": { "https://www.drupal.org/project/default_content/issues/2640734#comment-14638943": "https://raw.githubusercontent.com/City-of-Helsinki/drupal-helfi-platform-config/main/patches/default_content_2.0.0-alpha2-2640734_manual_imports-e164a354.patch" diff --git a/patches/3083786-duplicate-br-tags-2024-05-13.patch b/patches/3083786-duplicate-br-tags-2024-05-13.patch deleted file mode 100644 index 6f89ab054..000000000 --- a/patches/3083786-duplicate-br-tags-2024-05-13.patch +++ /dev/null @@ -1,43 +0,0 @@ -diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module -index c6cae99e5a..124668de0d 100644 ---- a/core/modules/filter/filter.module -+++ b/core/modules/filter/filter.module -@@ -755,9 +755,15 @@ function _filter_autop($text) { - $chunk = preg_replace('!

\s*(]*>)!', "$1", $chunk); - $chunk = preg_replace('!(]*>)\s*

!', "$1", $chunk); - // make line breaks -- $chunk = preg_replace('|(?)\s*\n|', "
\n", $chunk); -- $chunk = preg_replace('!(]*>)\s*
!', "$1", $chunk); -- $chunk = preg_replace('!
(\s*)!', '$1', $chunk); -+ $chunk = preg_replace_callback('|(]*>)?\s*\n|', function ($matches) { -+ if (isset($matches[1])) { -+ return $matches[1] . "\n"; -+ } -+ -+ return "
\n"; -+ }, $chunk); -+ $chunk = preg_replace('!(]*>)\s*]*/>!', "$1", $chunk); -+ $chunk = preg_replace('!]*>(\s*)!', '$1', $chunk); - $chunk = preg_replace('/&([^#])(?![A-Za-z0-9]{1,8};)/', '&$1', $chunk); - } - $output .= $chunk; -diff --git a/core/modules/filter/tests/src/Kernel/FilterKernelTest.php b/core/modules/filter/tests/src/Kernel/FilterKernelTest.php -index cfc8cdb503..0cdef41699 100644 ---- a/core/modules/filter/tests/src/Kernel/FilterKernelTest.php -+++ b/core/modules/filter/tests/src/Kernel/FilterKernelTest.php -@@ -469,6 +469,15 @@ class FilterKernelTest extends KernelTestBase { - '' => [ - '

' => FALSE, - ], -+ // Bug 3083786, duplicate br tags after a line ending in a break tag that -+ // doesn't exactly match
-+ 'aaa
-+ bbb
-+ ddd
' => [ -+ "

aaa
\n" => TRUE, -+ "bbb
\n" => TRUE, -+ "ddd

" => TRUE, -+ ], - ]; - // cSpell:enable - $this->assertFilteredString($filter, $tests); From 68f6ee53b9cf4d1ee63f0593837d52be783b102d Mon Sep 17 00:00:00 2001 From: Santeri Hurnanen Date: Tue, 14 May 2024 15:28:19 +0300 Subject: [PATCH 4/4] Update patch --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index fa593a7d1..034c05bb1 100644 --- a/composer.json +++ b/composer.json @@ -87,7 +87,7 @@ "[#UHF-7008] Admin toolbar and contextual links should always be rendered in the admin language (https://www.drupal.org/project/drupal/issues/2313309)": "https://www.drupal.org/files/issues/2023-12-19/2313309-179.patch", "[#UHF-9388] Process translation config files for custom modules (https://www.drupal.org/i/2845437)": "https://www.drupal.org/files/issues/2023-10-16/2845437-61.patch", "[#UHF-9690] Allow updating lists when switching from allowed values to allowed values function (https://www.drupal.org/i/2873353)": "https://www.drupal.org/files/issues/2021-05-18/allow-allowed-values-function-update-D9-2873353_1.patch", - "[#UHF-9952, #UHF-9980] Duplicate
tags (https://www.drupal.org/i/3083786)": "https://www.drupal.org/files/issues/2024-05-14/3083786-duplicate-br-tags-2024-05-14.patch" + "[#UHF-9952, #UHF-9980] Duplicate
tags (https://www.drupal.org/i/3083786)": "https://www.drupal.org/files/issues/2024-05-14/3083786-duplicate-br-tags-2024-05-14-no-tests.patch" }, "drupal/default_content": { "https://www.drupal.org/project/default_content/issues/2640734#comment-14638943": "https://raw.githubusercontent.com/City-of-Helsinki/drupal-helfi-platform-config/main/patches/default_content_2.0.0-alpha2-2640734_manual_imports-e164a354.patch"