diff options
| author | Aurélien Bompard | 2016-08-10 16:55:07 +0200 |
|---|---|---|
| committer | Barry Warsaw | 2016-08-23 21:53:55 -0400 |
| commit | 3667b6dbc4110b12dd625e458dcdc8b3d9da7817 (patch) | |
| tree | c25e7b2b179e66e243beb84a90024bcf959e1dff /src/mailman/rest/listconf.py | |
| parent | 711e2d20617ab85959a2446d610a860bdc306a54 (diff) | |
| download | mailman-3667b6dbc4110b12dd625e458dcdc8b3d9da7817.tar.gz mailman-3667b6dbc4110b12dd625e458dcdc8b3d9da7817.tar.zst mailman-3667b6dbc4110b12dd625e458dcdc8b3d9da7817.zip | |
Forbid newlines in MailingList.description
Fixes: #273
Diffstat (limited to 'src/mailman/rest/listconf.py')
| -rw-r--r-- | src/mailman/rest/listconf.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/mailman/rest/listconf.py b/src/mailman/rest/listconf.py index 0982e7970..c49228c39 100644 --- a/src/mailman/rest/listconf.py +++ b/src/mailman/rest/listconf.py @@ -101,6 +101,14 @@ def password_bytes_validator(value): return config.password_context.encrypt(value).encode('utf-8') +def no_newlines_validator(value): + value = str(value) + if '\n' in value: + raise ValueError( + 'This value must be on a single line: {}'.format(value)) + return value + + # This is the list of IMailingList attributes that are exposed through the # REST API. The values of the keys are the GetterSetter instance holding the # decoder used to convert the web request string to an internally valid value. @@ -136,7 +144,7 @@ ATTRIBUTES = dict( created_at=GetterSetter(None), default_member_action=GetterSetter(enum_validator(Action)), default_nonmember_action=GetterSetter(enum_validator(Action)), - description=GetterSetter(str), + description=GetterSetter(no_newlines_validator), digest_last_sent_at=GetterSetter(None), digest_send_periodic=GetterSetter(as_boolean), digest_size_threshold=GetterSetter(float), |
