Do not allow comma in SSH key name

This commit is contained in:
PCoder 2019-05-12 19:20:35 +02:00
parent c9c91b1ecb
commit 0104a804c2

View file

@ -1,8 +1,8 @@
import datetime import datetime
import logging import logging
import subprocess import subprocess
import tempfile import tempfile
from django import forms from django import forms
from django.conf import settings from django.conf import settings
from django.contrib.auth import authenticate from django.contrib.auth import authenticate
@ -214,6 +214,10 @@ class UserHostingKeyForm(forms.ModelForm):
return openssh_pubkey_str return openssh_pubkey_str
def clean_name(self): def clean_name(self):
INVALID_NAME_MESSAGE = _("Comma not accepted in the name of the key")
if "," in self.data.get('name'):
logger.debug(INVALID_NAME_MESSAGE)
raise forms.ValidationError(INVALID_NAME_MESSAGE)
return self.data.get('name') return self.data.get('name')
def clean_user(self): def clean_user(self):