From 55e1c7de4d7c36f659a9b77af5ed674637a1ec94 Mon Sep 17 00:00:00 2001
From: Oden <hello@odensc.com>
Date: Thu, 23 Jan 2025 20:29:36 -0800
Subject: [PATCH] Issue #3413647: Fix HTML tags getting double-encoded in
 data-caption

---
 src/Form/EntityEmbedDialog.php | 13 -------------
 1 file changed, 13 deletions(-)

diff --git a/src/Form/EntityEmbedDialog.php b/src/Form/EntityEmbedDialog.php
index e8befc9..aad8c21 100644
--- a/src/Form/EntityEmbedDialog.php
+++ b/src/Form/EntityEmbedDialog.php
@@ -537,7 +537,6 @@ class EntityEmbedDialog extends FormBase {
         '#type' => 'textarea',
         '#rows' => 3,
         '#default_value' => isset($entity_element['data-caption']) ? Html::decodeEntities($entity_element['data-caption']) : '',
-        '#element_validate' => ['::escapeValue'],
       ];
     }
 
@@ -850,18 +849,6 @@ class EntityEmbedDialog extends FormBase {
     return $response;
   }
 
-  /**
-   * Form element validation handler; Escapes the value an element.
-   *
-   * This should be used for any element in the embed form which may contain
-   * HTML that should be serialized as an attribute element on the embed.
-   */
-  public static function escapeValue($element, FormStateInterface $form_state) {
-    if ($value = trim($element['#value'])) {
-      $form_state->setValueForElement($element, Html::escape($value));
-    }
-  }
-
   /**
    * Returns the allowed display plugins given an embed button and an entity.
    *
-- 
GitLab