File tree 2 files changed +16
-0
lines changed 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change 9
9
unicode_literals ,
10
10
)
11
11
12
+ import re
12
13
from random import choice
13
14
14
15
from builtins import object
@@ -800,4 +801,8 @@ def clean_name(self):
800
801
raise forms .ValidationError (
801
802
_ ("Variable name can't contain spaces" ),
802
803
)
804
+ elif not re .fullmatch ('[a-zA-Z0-9_]+' , name ):
805
+ raise forms .ValidationError (
806
+ _ ('Only letters, numbers and underscore are allowed' ),
807
+ )
803
808
return name
Original file line number Diff line number Diff line change @@ -509,6 +509,17 @@ def test_use_invalid_names(self):
509
509
form .errors ['name' ],
510
510
)
511
511
512
+ data = {
513
+ 'name' : 'INVALID_CHAR*' ,
514
+ 'value' : 'string here' ,
515
+ }
516
+ form = EnvironmentVariableForm (data , project = self .project )
517
+ self .assertFalse (form .is_valid ())
518
+ self .assertIn (
519
+ 'Only letters, numbers and underscore are allowed' ,
520
+ form .errors ['name' ],
521
+ )
522
+
512
523
data = {
513
524
'name' : '__INVALID' ,
514
525
'value' : 'string here' ,
You can’t perform that action at this time.
0 commit comments