FIX Multi HTML entities in shortcodes

This commit is contained in:
Sabina Talipova 2023-08-07 16:23:46 +12:00
parent 2a56cc3ea4
commit 037168a4fe
2 changed files with 31 additions and 0 deletions

View File

@ -190,4 +190,14 @@ class HTMLEditorField extends TextareaField
$stateDefaults['data'] = $config->getConfigSchemaData(); $stateDefaults['data'] = $config->getConfigSchemaData();
return $stateDefaults; return $stateDefaults;
} }
/**
* Return value with all values encoded in html entities
*
* @return string Raw HTML
*/
public function ValueEntities()
{
return htmlentities($this->Value() ?? '', ENT_COMPAT, 'UTF-8', false);
}
} }

View File

@ -208,4 +208,25 @@ EOS
$readonlyContent->getValue() $readonlyContent->getValue()
); );
} }
public function testValueEntities()
{
$inputText = "The company & partners";
$field = new HTMLEditorField("Content");
$field->setValue($inputText);
$this->assertEquals(
"The company & partners",
$field->obj('ValueEntities')->forTemplate()
);
$inputText = "The company && partners";
$field = new HTMLEditorField("Content");
$field->setValue($inputText);
$this->assertEquals(
"The company && partners",
$field->obj('ValueEntities')->forTemplate()
);
}
} }