feat: disallow collisions with legacy draft names with capital letters (#5068)
This commit is contained in:
parent
2a1602d9bb
commit
189018a879
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue