def unquote_string(quoted):
 if (len(quoted) < 2):
  return quoted
 elif ((quoted[0] != '"') or (quoted[(-1)] != '"')):
  return quoted
 tmp_quoted = quoted[1:(-1)]
 if ('\\' not in tmp_quoted):
  return tmp_quoted
 elif ('\\\\' not in tmp_quoted):
  return tmp_quoted.replace('\\', '')
 else:
  return '\\'.join([q.replace('\\', '') for q in tmp_quoted.split('\\\\')])

def unquote_string ( quoted ) : if ( len ( quoted ) < 2 ) : return quoted elif ( ( quoted [ 0 ] != '"' ) or ( quoted [ ( - 1 ) ] != '"' ) ) : return quoted tmp_quoted = quoted [ 1 : ( - 1 ) ] if ( '\\' not in tmp_quoted ) : return tmp_quoted elif ( '\\\\' not in tmp_quoted ) : return tmp_quoted . replace ( '\\' , '' ) else : return '\\' . join ( [ q . replace ( '\\' , '' ) for q in tmp_quoted . split ( '\\\\' ) ] )
unquote an rfc 7320 "quoted-string" .