Created
May 22, 2013 17:01
-
-
Save hub-cap/5629160 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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