You are here

public static function ConversionHelper::unescapeDnValue in Lightweight Directory Access Protocol (LDAP) 8.4

Same name and namespace in other branches
  1. 8.3 ldap_servers/src/Helper/ConversionHelper.php \Drupal\ldap_servers\Helper\ConversionHelper::unescapeDnValue()

Undoes the conversion done by escape_dn_value().

Any escape sequence starting with a baskslash - hexpair or special character - will be transformed back to the corresponding character.

Parameters

string $value: DN Value.

Return value

string Same as $value, but unescaped

5 calls to ConversionHelper::unescapeDnValue()
ConversionHelperTest::testUnescape in ldap_servers/tests/src/Unit/ConversionHelperTest.php
Test the unescape mechanism.
LDAPAuthorizationProvider::sanitizeProposals in ldap_authorization/src/Plugin/authorization/Provider/LDAPAuthorizationProvider.php
Sanitize proposals.
LdapGroupManager::getAllRdnValuesFromDn in ldap_servers/src/LdapGroupManager.php
Returns all RDN values from DN.
LdapGroupManager::getFirstRdnValueFromDn in ldap_servers/src/LdapGroupManager.php
Return the first RDN Value from DN.
TokenProcessor::processDnParts in ldap_servers/src/Processor/TokenProcessor.php
Deconstruct DN parts.

File

ldap_servers/src/Helper/ConversionHelper.php, line 24

Class

ConversionHelper
Conversion helper to escape values correctly for LDAP filters.

Namespace

Drupal\ldap_servers\Helper

Code

public static function unescapeDnValue(string $value) : string {

  // Strip slashes from special chars.
  $value = str_replace('\\\\', '\\', $value);
  $value = str_replace('\\,', ',', $value);
  $value = str_replace('\\+', '+', $value);
  $value = str_replace('\\"', '"', $value);
  $value = str_replace('\\<', '<', $value);
  $value = str_replace('\\>', '>', $value);
  $value = str_replace('\\;', ';', $value);
  $value = str_replace('\\#', '#', $value);
  $value = str_replace('\\=', '=', $value);

  // Translate hex code into ascii.
  return self::hex2string($value);
}