Fix unicode in error message about ssh keys
authorMagnus Hagander <magnus@hagander.net>
Wed, 26 Dec 2018 11:44:25 +0000 (12:44 +0100)
committerMagnus Hagander <magnus@hagander.net>
Wed, 26 Dec 2018 11:45:17 +0000 (12:45 +0100)
Caused an exception when somebody tried to upload an SSH key where the
*key type* contains non-ascii (this would normally be things like
"ssh-rsa", and there are definitely no legit key types outside the ascii
range, but we still shouldn't crash)

pgweb/core/models.py

index 95a4cfa8a42345a6dbf9e391b74b92cbc59fe581..8edb07bb3f3ce6dff15b237bd73e3b99e204c877 100644 (file)
@@ -179,7 +179,7 @@ def validate_sshkey(key):
                if pieces[0] == 'ssh-dss':
                        raise ValidationError("For security reasons, ssh-dss keys are not supported")
                if pieces[0] not in _valid_keytypes:
-                       raise ValidationError("Only keys of types {0} are supported, not {1}.".format(", ".join(_valid_keytypes), pieces[0]))
+                       raise ValidationError(u"Only keys of types {0} are supported, not {1}.".format(", ".join(_valid_keytypes), pieces[0]))
                try:
                        base64.b64decode(pieces[1])
                except: