feat: disallow collisions with legacy draft names with capital letters (#5068)

This commit is contained in:
Robert Sparks 2023-02-01 15:11:19 -06:00 committed by GitHub
parent 2a1602d9bb
commit 189018a879
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 0 deletions

View file

@ -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)

View file

@ -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)