@@ -239,6 +239,15 @@ class StringField(Field):
239239 """
240240 def _validate (self , * args , ** kwargs ):
241241 errors = super (StringField , self )._validate (* args , ** kwargs )
242+ no_special_char_field = ['license_expression' , 'license_key' , 'license_name' ]
243+ name = self .name
244+ if name in no_special_char_field :
245+ val = self .value
246+ special_char = detect_special_char (val )
247+ if special_char :
248+ msg = (u'The following character(s) cannot be in the %(name)s: '
249+ '%(special_char)r' % locals ())
250+ errors .append (Error (ERROR , msg ))
242251 return errors
243252
244253 def _serialized_value (self ):
@@ -1388,7 +1397,7 @@ def pre_process_and_fetch_license_dict(abouts, api_url, api_key):
13881397 if about .license_expression .present :
13891398 special_char_in_expression , lic_list = parse_license_expression (about .license_expression .value )
13901399 if special_char_in_expression :
1391- msg = (u"The following character(s) cannot be in the licesne_expression : " +
1400+ msg = (u"The following character(s) cannot be in the license_expression : " +
13921401 str (special_char_in_expression ))
13931402 errors .append (Error (ERROR , msg ))
13941403 else :
@@ -1412,20 +1421,20 @@ def pre_process_and_fetch_license_dict(abouts, api_url, api_key):
14121421def parse_license_expression (lic_expression ):
14131422 licensing = Licensing ()
14141423 lic_list = []
1415- special_char = special_char_in_license_expresion (lic_expression )
1424+ special_char = detect_special_char (lic_expression )
14161425 if not special_char :
14171426 # Parse the license expression and save it into a list
14181427 lic_list = licensing .license_keys (lic_expression )
14191428 return special_char , lic_list
14201429
14211430
1422- def special_char_in_license_expresion ( lic_expression ):
1431+ def detect_special_char ( expression ):
14231432 not_support_char = [
14241433 '!' , '@' , '#' , '$' , '%' , '^' , '&' , '*' , '=' , '{' , '}' ,
14251434 '|' , '[' , ']' , '\\ ' , ':' , ';' , '<' , '>' , '?' , ',' , '/' ]
14261435 special_character = []
14271436 for char in not_support_char :
1428- if char in lic_expression :
1437+ if char in expression :
14291438 special_character .append (char )
14301439 return special_character
14311440
0 commit comments