Skip to content

Commit 5e8f3a5

Browse files
Merge pull request #10 from Cyber-Duck/feature/patch-textarea-readonly
StripTags instead of escaping the HTML data
2 parents e7ff497 + 5eab280 commit 5e8f3a5

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

src/Column.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,8 +427,10 @@ private function markupField(FormBuilder $formBuilder)
427427

428428
case "text-readonly": /* Render text into the form and add a hidden field */
429429
case "number-readonly":
430-
case "textarea-readonly": /* Render text into the form and add a hidden field */
431430
$this->value = OutputHelper::output($this->value);
431+
case "textarea-readonly": /* Render text into the form and add a hidden field */
432+
$this->value = $this->stripTagsTextarea();
433+
432434
if (!empty($this->value) || $this->value === 0) {
433435
$output .= '<div class="' . $this->classBundle . '">';
434436
$output .= '<div class="section-readonly">';
@@ -489,6 +491,7 @@ private function markupField(FormBuilder $formBuilder)
489491
return Form::text($this->fieldNameWithBrackets, $this->value, $this->asFormArray());
490492

491493
case 'textarea':
494+
$this->value = $this->stripTagsTextarea();
492495

493496
return Field::{$this->type}($this->fieldNameWithBrackets, htmlspecialchars($this->value), $this->asFormArray());
494497

@@ -731,4 +734,25 @@ private function parseDefaultValue(FormBuilder $formBuilder)
731734

732735
return $this->default_value;
733736
}
737+
738+
/**
739+
* @return string
740+
*/
741+
protected function stripTagsTextarea(): string
742+
{
743+
return strip_tags($this->value, [
744+
'p',
745+
'strong',
746+
'em',
747+
'b',
748+
'i',
749+
'ol',
750+
'ul',
751+
'li',
752+
'br',
753+
'span',
754+
'div',
755+
'wbr'
756+
]);
757+
}
734758
}

0 commit comments

Comments
 (0)