Unespaces an LDAP string

    :param ldap_string: The string to unescape
    :return: The unprotected string
195222
def unescape_LDAP(ldap_string):
    # type: (str) -> str
    # pylint: disable=C0103
    
    if ldap_string is None:
        return None

    if ESCAPE_CHARACTER not in ldap_string:
        # No need to loop
        return ldap_string

    escaped = False
    result = ""

    for character in ldap_string:
        if not escaped and character == ESCAPE_CHARACTER:
            # Escape character found
            escaped = True
        else:
            # Copy the character
            escaped = False
            result += character

    return result
572935
def deobfuscate(cls, data):
        
        # the str() call is necessary to convert the unicode string
        # to an ascii string since the urlsafe_b64decode method
        # sometimes chokes on unicode strings
        return base64.urlsafe_b64decode(str((
            data + b'A=='[(len(data) - 1) % 4:])))
872462
public static String unescapeString(String escapedString) {
        Matcher match = escapeSequence.matcher(escapedString);
        StringBuffer output = new StringBuffer();
        while(match.find()) {
            match.appendReplacement(output, substitution(match.group()));
        }
        match.appendTail(output);
        return output.toString();
    }
800798
def _unescape(self, value):
    '''
    
    '''
    if isinstance(value, (str,unicode)):
      return value.replace(self._escape_character, '.')
    elif isinstance(value, dict):
      return { self._unescape(k) : self._unescape(v) for k,v in value.items() }
    elif isinstance(value, list):
      return [ self._unescape(v) for v in value ]
    return value
471245
public static String unescapeNewlines(String str) {
    boolean hadSlash = false;
    final int len = str.length();
    StringWriter out = new StringWriter(len);
    for (int i = 0; i < len; i++) {
      char c = str.charAt(i);
      if (hadSlash) {
        switch (c) {
          case 'n':
            out.write('\n');
            break;
          case '\\':
            out.write('\\');
            break;
          default:
            out.write(c);
        }
        hadSlash = false;
      } else {
        if (c == '\\')
          hadSlash = true;
        else
          out.write(c);
      }
    }
    return out.toString();
  }
112890
def resourceprep(string, allow_unassigned=False):
    

    chars = list(string)
    _resourceprep_do_mapping(chars)
    do_normalization(chars)
    check_prohibited_output(
        chars,
        (
            stringprep.in_table_c12,
            stringprep.in_table_c21,
            stringprep.in_table_c22,
            stringprep.in_table_c3,
            stringprep.in_table_c4,
            stringprep.in_table_c5,
            stringprep.in_table_c6,
            stringprep.in_table_c7,
            stringprep.in_table_c8,
            stringprep.in_table_c9,
        ))
    check_bidi(chars)

    if not allow_unassigned:
        check_unassigned(
            chars,
            (
                stringprep.in_table_a1,
            )
        )

    return "".join(chars)
79547
protected String encodeLdap() {
		StringBuffer buff = new StringBuffer(key.length() + value.length() * 2);

		buff.append(key);
		buff.append('=');
		buff.append(LdapEncoder.nameEncode(value));

		return buff.toString();
	}
1242912
private static final String unescape(String str) {
        StringBuilder sb = new StringBuilder(str.length() * 2);
        int len = str.length();
        for (int i = 0; i < len; i++) {
            char c = str.charAt(i);
            if ((c == '\\') && (i < len - 1)) {
                char d = str.charAt(i + 1);
                if (!((d == USER_DATA_DELIM) || (d == USER_ATTRIB_DELIM) || (d == TOKEN_DELIM))) {
                    // if next char is delim, skip this escape char
                    sb.append(c);
                }
            } else {
                sb.append(c);
            }
        }
        return sb.toString();
    }
772601
def _usage_unallocated(raw):
    '''
    
    '''
    ret = {}
    for line in raw.split("\n")[1:]:
        keyset = re.sub(r"\s+", " ", line.strip()).split(" ")
        if len(keyset) == 2:
            ret[keyset[0]] = keyset[1]

    return ret
1173565
def _unwrap_dict(dictionary, index_string):
    '''
    
    '''
    index = index_string.split(',')
    for k in index:
        dictionary = dictionary[k]
    return dictionary
506643
function ldap_slashes($str){
        $illegal=array("(",")","#"); // the + character has problems too, but it's an illegal character
        
        $legal=array();
        foreach ($illegal as $id => $char){ $legal[$id]="\\".$char; } //make up the array of legal chars
        
        $str=str_replace($illegal,$legal,$str); //replace them
        return ($str);
    }
280767
def unescape_json_str(st):
    
    c = 0
    ln = len(st)
    escape_chmap = {
        b'b': b'\b',
        b'f': b'\f',
        b'n': b'\n',
        b'r': b'\r',
        b't': b'\t',
        b'\\': b'\\',
        b'"': b'\"',
        b'/': b'\/'
    }

    ret = []

    def at(i):
        return st[i:i+1]

    while c < ln:
        if at(c) == b'\\':
            if at(c+1) == b'u':
                ret.append(bytes([int(st[c+2:c+6], 16)]))
                # ret.append(st[c:c+6].decode('unicode_escape').encode('utf8'))
                c += 6

            else:
                ret.append(escape_chmap[at(c+1)])
                c += 2

        else:
            ret.append(at(c))
            c += 1

    df = (b''.join(ret))
    return df
61494
function unescapeString(str) {
    let i = 0, result = '';
    const len = str.length;

    while (i < len) {
        const ch = str[i++];
        result += (ch === '\\') ? (str[i++] || '') : ch;
    }

    return result;
}
318128
def _unescape(self, msg):
        
        if isinstance(msg, (int, float, long)):
            return msg

        unescaped = ''
        i = 0
        while i < len(msg):
            unescaped += msg[i]
            if msg[i] == '"':
                i+=1
            i+=1
        return unescaped
69719
function unescape(str) {
        return str.replace(/&amp;/g, '&').replace(/&quot;/g, '"').replace(/&#x27;/g, '\'').replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&#x2F;/g, '/').replace(/&#x5C;/g, '\\').replace(/&#96;/g, '`');
    }
867666
static void unescapePrintf(StringBuilder out, String message, int start, int end) {
    int pos = start;
    while (pos < end) {
      if (message.charAt(pos++) != '%') {
        continue;
      }
      if (pos == end) {
        // Ignore unexpected trailing '%'.
        break;
      }
      char chr = message.charAt(pos);
      if (chr == '%') {
        // Append the section up to and including the first '%'.
        out.append(message, start, pos);
      } else if (chr == 'n') {
        // %n encountered, rewind one position to not emit leading '%' and emit newline.
        out.append(message, start, pos - 1);
        out.append(SYSTEM_NEWLINE);
      } else {
        // A single unescaped '%' is ignored and left in the output as-is.
        continue;
      }
      // Increment the position and reset the start point after the last processed character.
      start = ++pos;
    }
    // Append the last section (if it's non empty).
    if (start < end) {
      out.append(message, start, end);
    }
  }
1125245
public function unescape()
 	{
		$length			= $this->getLength();
		$this->string	= stripslashes( $this->string );
		return $length - $this->getLength();
 	}