Merge pull request #10903 from creative-commoners/pulls/4.13/fix-multi-html-entities-in-shortcode

FIX Multi HTML entities in short codes
This commit is contained in:
Guy Sartorelli 2023-08-08 13:20:17 +12:00 committed by GitHub
commit 4f6ab330f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 0 deletions

View File

@ -190,4 +190,14 @@ class HTMLEditorField extends TextareaField
$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);
}
}

View File

@ -208,4 +208,25 @@ EOS
$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()
);
}
}