Skip to content

Instantly share code, notes, and snippets.

@hub-cap
Created May 22, 2013 17:01
Show Gist options
  • Select an option

  • Save hub-cap/5629160 to your computer and use it in GitHub Desktop.

Select an option

Save hub-cap/5629160 to your computer and use it in GitHub Desktop.
def unquote_user_host(user_hostname):
unquoted = unquote(user_hostname)
if '@' not in unquoted:
- return unquoted, '%'
- if unquoted.endswith('@'):
- return unquoted, '%'
- splitup = unquoted.split('@')
- host = splitup[-1]
- user = '@'.join(splitup[:-1])
+ user, host = unquoted, '%'
+ elif unquoted.endswith('@'):
+ user, host = unquoted, '%'
+ else:
+ splitup = unquoted.split('@')
+ host = splitup[-1]
+ user = '@'.join(splitup[:-1])
+ # un-escape
+ user = user.replace("\\.", ".")
+ host = host.replace("\\.", ".")
return user, host
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment