function Html::decodeEntities
Same name in other branches
- 9 core/lib/Drupal/Component/Utility/Html.php \Drupal\Component\Utility\Html::decodeEntities()
- 8.9.x core/lib/Drupal/Component/Utility/Html.php \Drupal\Component\Utility\Html::decodeEntities()
- 11.x core/lib/Drupal/Component/Utility/Html.php \Drupal\Component\Utility\Html::decodeEntities()
Decodes all HTML entities including numerical ones to regular UTF-8 bytes.
Double-escaped entities will only be decoded once ("&lt;" becomes "<", not "<"). Be careful when using this function, as it will revert previous sanitization efforts (<script> will become <script>).
This method is not the opposite of Html::escape(). For example, this method will convert "é" to "é", whereas Html::escape() will not convert "é" to "é".
Parameters
string $text: The text to decode entities in.
Return value
string The input $text, with all HTML entities decoded once.
See also
\Drupal\Component\Utility\Html::escape()
38 calls to Html::decodeEntities()
- BigPipe::sendPlaceholders in core/
modules/ big_pipe/ src/ Render/ BigPipe.php - Sends BigPipe placeholders' replacements as embedded AJAX responses.
- BigPipeTest::assertBigPipePlaceholders in core/
modules/ big_pipe/ tests/ src/ Functional/ BigPipeTest.php - Asserts expected BigPipe placeholders are present and replaced.
- CommentAdminTest::testApprovalAdminInterface in core/
modules/ comment/ tests/ src/ Functional/ Views/ CommentAdminTest.php - Tests comment approval functionality through admin/content/comment.
- CommentForm::buildEntity in core/
modules/ comment/ src/ CommentForm.php - Builds an updated entity object based upon the submitted form values.
- ContextualLinks::render in core/
modules/ contextual/ src/ Plugin/ views/ field/ ContextualLinks.php - Overrides \Drupal\views\Plugin\views\field\FieldPluginBase::render().
File
-
core/
lib/ Drupal/ Component/ Utility/ Html.php, line 393
Class
- Html
- Provides DOMDocument helpers for parsing and serializing HTML strings.
Namespace
Drupal\Component\UtilityCode
public static function decodeEntities($text) : string {
if (is_null($text)) {
@trigger_error('Passing NULL to ' . __METHOD__ . ' is deprecated in drupal:9.5.0 and will trigger a PHP error from drupal:11.0.0. Pass a string instead. See https://www.drupal.org/node/3318826', E_USER_DEPRECATED);
return '';
}
return html_entity_decode($text, ENT_QUOTES, 'UTF-8');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.