From 679a254903f94ef11c0a083fc9a386bd65ed2b21 Mon Sep 17 00:00:00 2001
From: anjaliprasannan <anjaliprasannan243@gmail.com>
Date: Fri, 4 Apr 2025 23:00:45 +0530
Subject: [PATCH] Issue #3202900 by klimp: Views grouping field is
 double-escaped

---
 .../views/src/Plugin/views/style/StylePluginBase.php       | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/core/modules/views/src/Plugin/views/style/StylePluginBase.php b/core/modules/views/src/Plugin/views/style/StylePluginBase.php
index 1831fdb672bc..e11dbb89c48d 100644
--- a/core/modules/views/src/Plugin/views/style/StylePluginBase.php
+++ b/core/modules/views/src/Plugin/views/style/StylePluginBase.php
@@ -5,6 +5,7 @@
 use Drupal\Component\Utility\Html;
 use Drupal\Component\Utility\Xss;
 use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\Render\Markup;
 use Drupal\views\Plugin\views\display\DisplayPluginBase;
 use Drupal\views\Plugin\views\PluginBase;
 use Drupal\views\Plugin\views\wizard\WizardInterface;
@@ -575,13 +576,13 @@ public function renderGrouping($records, $groupings = [], $group_rendered = NULL
           // we can control any special formatting of the grouping field through
           // the admin or theme layer or anywhere else we'd like.
           if (isset($this->view->field[$field])) {
-            $group_content = $this->getField($index, $field);
+            $group_content = (string) $this->getField($index, $field);
             if ($this->view->field[$field]->options['label']) {
               $delimiter = $this->view->field[$field]->options['element_label_colon'] ? ': ' : ' ';
               $group_content = $this->view->field[$field]->options['label'] . $delimiter . $group_content;
             }
             if ($rendered) {
-              $grouping = (string) $group_content;
+              $grouping = $group_content;
               if ($rendered_strip) {
                 $group_content = $grouping = strip_tags(htmlspecialchars_decode($group_content));
               }
@@ -598,7 +599,7 @@ public function renderGrouping($records, $groupings = [], $group_rendered = NULL
 
           // Create the group if it does not exist yet.
           if (empty($set[$grouping])) {
-            $set[$grouping]['group'] = $group_content;
+            $set[$grouping]['group'] = Markup::create($group_content);
             $set[$grouping]['level'] = $level;
             $set[$grouping]['rows'] = [];
           }
-- 
GitLab