Skip to content

Commit

Permalink
FIX Multi HTML entities in shortcodes
Browse files Browse the repository at this point in the history
  • Loading branch information
sabina-talipova committed Aug 8, 2023
1 parent 2a56cc3 commit 037168a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Forms/HTMLEditor/HTMLEditorField.php
Expand Up @@ -190,4 +190,14 @@ public function getSchemaStateDefaults()
$stateDefaults['data'] = $config->getConfigSchemaData();
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);
}
}
21 changes: 21 additions & 0 deletions tests/php/Forms/HTMLEditor/HTMLEditorFieldTest.php
Expand Up @@ -208,4 +208,25 @@ public function testReadonlyField()
$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()
);
}
}

0 comments on commit 037168a

Please sign in to comment.