Commit fea5c2a2 authored by renatog's avatar renatog Committed by renatog
Browse files

Issue #3270528 by RenatoG: Prevent attribute id and class inside of form validation

parent e854e8f1
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -396,6 +396,26 @@ class BlockClassHelperService {

      $form_state->setErrorByName('third_party_settings[block_class][attributes]', $this->t("You need to insert a pipe on attributes field"));

      return FALSE;

    }

    // Prevent attribute id.
    if (str_contains($attributes, 'id|')) {

      $form_state->setErrorByName('third_party_settings[block_class][attributes]', $this->t("You can't the attribute id"));

      return FALSE;

    }

    // Prevent attribute class.
    if (str_contains($attributes, 'class|')) {

      $form_state->setErrorByName('third_party_settings[block_class][attributes]', $this->t("You can't use class. Use the field class instead"));

      return FALSE;

    }

    // If it's only one line, skip.
@@ -408,7 +428,11 @@ class BlockClassHelperService {
    foreach ($attributes as $attribute) {

      if (!str_contains($attribute, '|')) {

        $form_state->setErrorByName('third_party_settings[block_class][attributes]', $this->t("You need to insert a pipe on attributes field"));

        return FALSE;

      }

    }