Skip to content

Commit 5006ea5

Browse files
authored
fix: Reject obvious bad encoding pastes into the Submitter field in submissions (ietf-tools#6702)
1 parent b78f5ba commit 5006ea5

2 files changed

Lines changed: 35 additions & 2 deletions

File tree

ietf/submit/forms.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright The IETF Trust 2011-2022, All Rights Reserved
1+
# Copyright The IETF Trust 2011-2023, All Rights Reserved
22
# -*- coding: utf-8 -*-
33

44

@@ -758,6 +758,20 @@ def cleaned_line(self):
758758
line = formataddr((line, email))
759759
return line
760760

761+
def clean_name(self):
762+
name = super(SubmitterForm, self).clean_name()
763+
if name.startswith('=?'):
764+
msg = f'"{name}" appears to be a MIME-encoded string.'
765+
try:
766+
import email.header
767+
text, encoding = email.header.decode_header(name)[0]
768+
decoded_name = text.decode(encoding)
769+
msg += f' Did you mean "{decoded_name}"?'
770+
except:
771+
pass
772+
raise forms.ValidationError(msg)
773+
return name
774+
761775
class ReplacesForm(forms.Form):
762776
replaces = SearchableDocAliasesField(required=False, help_text="Any Internet-Drafts that this document replaces (approval required for replacing an Internet-Draft you are not the author of)")
763777

ietf/submit/tests.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright The IETF Trust 2011-2022, All Rights Reserved
1+
# Copyright The IETF Trust 2011-2023, All Rights Reserved
22
# -*- coding: utf-8 -*-
33

44

@@ -495,6 +495,25 @@ def test_submit_new_wg_as_author(self):
495495
self.assertEqual(r.status_code, 200)
496496
self.assertContains(r, 'The submission is pending approval by the group chairs.')
497497

498+
def test_submit_new_wg_as_author_bad_submitter(self):
499+
# submit new -> supply submitter info -> approve
500+
mars = GroupFactory(type_id='wg', acronym='mars')
501+
draft = WgDraftFactory(group=mars)
502+
setup_default_community_list_for_group(draft.group)
503+
504+
name = "draft-ietf-mars-testing-tests"
505+
rev = "00"
506+
group = "mars"
507+
508+
status_url, author = self.do_submission(name, rev, group)
509+
username = author.user.email
510+
511+
# supply submitter info with MIME-encoded name
512+
self.client.login(username=username, password=username+'+password') # log in as the author
513+
r = self.supply_extra_metadata(name, status_url, '=?utf-8?q?Peter_Christen_Asbj=C3=B8rnsen?=', author.email().address.lower(), replaces=[])
514+
self.assertEqual(r.status_code, 200)
515+
self.assertContains(r, 'appears to be a MIME-encoded string')
516+
498517
def submit_new_concluded_wg_as_author(self, group_state_id='conclude'):
499518
"""A new concluded WG submission by a logged-in author needs AD approval"""
500519
mars = GroupFactory(type_id='wg', acronym='mars', state_id=group_state_id)

0 commit comments

Comments
 (0)