Comment 5 for bug 784825

Revision history for this message
Brian Murray (brian-murray) wrote :

Still says TODO:

def check_hostname(hostname):
    """Returns a newline separated string of reasons why the hostname is
    invalid."""
    # TODO: i18n
    e = []
    # Ahem. We can cheat here by inserting newlines where needed. Hopefully
    # by the time we translate this, GTK+ will have decent layout management.
    for result in validation.check_hostname(utf8(hostname)):
        if result == validation.HOSTNAME_LENGTH:
            e.append("Must be between 1 and 63 characters long.")
        elif result == validation.HOSTNAME_BADCHAR:
            e.append("May only contain letters, digits,\nhyphens, and dots.")
        elif result == validation.HOSTNAME_BADHYPHEN:
            e.append("May not start or end with a hyphen.")
        elif result == validation.HOSTNAME_BADDOTS:
            e.append('May not start or end with a dot,\n'
                     'or contain the sequence "..".')
    return "\n".join(e)