From 0104a804c26acc1ded1d67e6007ccdfd8ba021c2 Mon Sep 17 00:00:00 2001 From: PCoder Date: Sun, 12 May 2019 19:20:35 +0200 Subject: [PATCH] Do not allow comma in SSH key name --- hosting/forms.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hosting/forms.py b/hosting/forms.py index 16b06fe0..576a1996 100644 --- a/hosting/forms.py +++ b/hosting/forms.py @@ -1,8 +1,8 @@ import datetime import logging import subprocess - import tempfile + from django import forms from django.conf import settings from django.contrib.auth import authenticate @@ -214,6 +214,10 @@ class UserHostingKeyForm(forms.ModelForm): return openssh_pubkey_str 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') def clean_user(self):