From 189018a879975027dacea1e1ed4dcb8bc6a44565 Mon Sep 17 00:00:00 2001 From: Robert Sparks Date: Wed, 1 Feb 2023 15:11:19 -0600 Subject: [PATCH] feat: disallow collisions with legacy draft names with capital letters (#5068) --- ietf/submit/forms.py | 13 +++++++++++++ ietf/submit/tests.py | 12 ++++++++++++ 2 files changed, 25 insertions(+) diff --git a/ietf/submit/forms.py b/ietf/submit/forms.py index 7a4bd38f1..238a621c1 100644 --- a/ietf/submit/forms.py +++ b/ietf/submit/forms.py @@ -251,6 +251,8 @@ class SubmissionBaseUploadForm(forms.Form): "element has a docName attribute which provides the full draft name including " "revision number.") + self.check_for_old_uppercase_collisions(self.filename) + if self.cleaned_data.get('txt') or self.cleaned_data.get('xml'): # check group self.group = self.deduce_group(self.filename) @@ -284,6 +286,17 @@ class SubmissionBaseUploadForm(forms.Form): ) return super().clean() + @staticmethod + def check_for_old_uppercase_collisions(name): + possible_collision = Document.objects.filter(name__iexact=name).first() + if possible_collision and possible_collision.name != name: + raise forms.ValidationError( + f"Case-conflicting draft name found: {possible_collision.name}. " + "Please choose a different draft name. Case-conflicting names with " + "the small number of legacy Internet-Drafts with names containing " + "upper-case letters are not permitted." + ) + @staticmethod def check_submissions_thresholds(which, filter_kwargs, max_amount, max_size): submissions = Submission.objects.filter(**filter_kwargs) diff --git a/ietf/submit/tests.py b/ietf/submit/tests.py index ad1891c95..e3d97a2e6 100644 --- a/ietf/submit/tests.py +++ b/ietf/submit/tests.py @@ -3638,3 +3638,15 @@ class ValidateSubmissionFilenameTests(BaseSubmitTestCase): msg = validate_submission_rev(new_wg_doc.name, '02') self.assertIsNone(msg) + +class TestOldNamesAreProtected(BaseSubmitTestCase): + + def test_submit_case_conflited_name_fails(self): + WgDraftFactory(name="draft-something-HasCapitalLetters") + with self.assertRaisesMessage(ValidationError, "Case-conflicting draft name found"): + SubmissionBaseUploadForm.check_for_old_uppercase_collisions("draft-something-hascapitalletters") + url = urlreverse("ietf.submit.views.upload_submission") + files = {} + files["xml"], _ = submission_file("draft-something-hascapitalletters-00", "draft-something-hascapitalletters-00.xml", None, "test_submission.xml") + r = self.client.post(url, files) + self.assertContains(r,"Case-conflicting draft name found",status_code=200)