diff --git a/core/lib/Drupal/Core/Form/ConfigFormBase.php b/core/lib/Drupal/Core/Form/ConfigFormBase.php index 6436eaebe694714aec12d5b6e0bcc04fa72727fd..00381d287baa89539240c56bed2a1202b705dd94 100644 --- a/core/lib/Drupal/Core/Form/ConfigFormBase.php +++ b/core/lib/Drupal/Core/Form/ConfigFormBase.php @@ -7,7 +7,8 @@ use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Config\TypedConfigManagerInterface; use Drupal\Core\Render\Element; -use Drupal\Core\StringTranslation\TranslatableMarkup; +use Drupal\Component\Render\MarkupInterface; +use Drupal\Core\Render\Markup; use Drupal\Core\Url; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -276,9 +277,10 @@ public function validateForm(array &$form, FormStateInterface $form_state) { * @param \Symfony\Component\Validator\ConstraintViolationListInterface $violations * The list of constraint violations that apply to this form element. * - * @return \Drupal\Core\StringTranslation\TranslatableMarkup + * @return \Drupal\Component\Render\MarkupInterface|\Stringable + * The rendered HTML. */ - protected function formatMultipleViolationsMessage(string $form_element_name, array $violations): TranslatableMarkup { + protected function formatMultipleViolationsMessage(string $form_element_name, array $violations): MarkupInterface|\Stringable { $transformed_message_parts = []; foreach ($violations as $index => $violation) { // Note that `@validation_error_message` (should) already contain a @@ -291,7 +293,9 @@ protected function formatMultipleViolationsMessage(string $form_element_name, ar '@validation_error_message' => $violation->getMessage(), ]); } - return $this->t(implode("\n", $transformed_message_parts)); + // We use \Drupal\Core\Render\Markup::create() here as it is safe, + // rather than use t() because all input has been escaped by t(). + return Markup::create(implode("\n", $transformed_message_parts)); } /**