public static function String::decodeEntities

Decodes all HTML entities including numerical ones to regular UTF-8 bytes.

Double-escaped entities will only be decoded once ("&amp;lt;" becomes "&lt;", not "<"). Be careful when using this function, as it will revert previous sanitization efforts (&lt;script&gt; will become <script>).

Parameters

string $text: The text to decode entities in.

Return value

string The input $text, with all HTML entities decoded once.

5 calls to String::decodeEntities()
decode_entities in drupal/core/includes/unicode.inc
Decodes all HTML entities (including numerical ones) to regular UTF-8 bytes.
StringTest::testDecodeEntities in drupal/core/tests/Drupal/Tests/Component/Utility/StringTest.php
Tests String::decodeEntities().
UrlValidator::filterBadProtocol in drupal/core/lib/Drupal/Component/Utility/UrlValidator.php
Processes an HTML attribute value and strips dangerous protocols from URLs.
XssTest::assertNormalized in drupal/core/tests/Drupal/Tests/Component/Utility/XssTest.php
Asserts that a text transformed to lowercase with HTML entities decoded does contains a given string.
XssTest::assertNotNormalized in drupal/core/tests/Drupal/Tests/Component/Utility/XssTest.php
Asserts that text transformed to lowercase with HTML entities decoded does not contain a given string.

File

drupal/core/lib/Drupal/Component/Utility/String.php, line 48
Contains \Drupal\Component\Utility\String.

Class

String
Provides helpers to operate on strings.

Namespace

Drupal\Component\Utility

Code

public static function decodeEntities($text) {
  return html_entity_decode($text, ENT_QUOTES, 'UTF-8');
}