You are here

function ldap_pear_unescape_dn_value in Lightweight Directory Access Protocol (LDAP) 7

Same name and namespace in other branches
  1. 8.2 ldap_servers/ldap_servers.functions.inc \ldap_pear_unescape_dn_value()
  2. 7.2 ldap_servers/ldap_servers.functions.inc \ldap_pear_unescape_dn_value()

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.

@static

Parameters

array $values Array of DN Values:

Return value

array Same as $values, but unescaped

3 calls to ldap_pear_unescape_dn_value()
LdapAuthenticationTestCase::AttemptLogon in ldap_authentication/tests/ldap_authentication.test
ldap_server_tokenize_entry in ldap_servers/ldap_servers.functions.inc
Turn an ldap entry into a token array suitable for the t() function
_ldap_authorization_ldap_authorization_maps_alter in ldap_authorization/ldap_authorization.inc

File

ldap_servers/ldap_servers.functions.inc, line 559
collection of functions that don't belong in server object

Code

function ldap_pear_unescape_dn_value($values = array()) {
  $is_scalar = is_scalar($values);

  // Parameter validation
  if (!is_array($values)) {
    $values = array(
      $values,
    );
  }
  foreach ($values as $key => $val) {

    // strip slashes from special chars
    $val = str_replace('\\\\', '\\', $val);
    $val = str_replace('\\,', ',', $val);
    $val = str_replace('\\+', '+', $val);
    $val = str_replace('\\"', '"', $val);
    $val = str_replace('\\<', '<', $val);
    $val = str_replace('\\>', '>', $val);
    $val = str_replace('\\;', ';', $val);
    $val = str_replace('\\#', '#', $val);
    $val = str_replace('\\=', '=', $val);

    // Translate hex code into ascii
    $values[$key] = ldap_pear_hex2asc($val);
  }
  return $is_scalar ? $values[0] : $values;
}