From 507855a67380005251951718e5a04a80a32abab1 Mon Sep 17 00:00:00 2001 From: Jennifer Richards Date: Wed, 31 May 2023 16:23:18 -0300 Subject: [PATCH 1/3] fix: Accept a Path as source for a PlaintextDraft --- ietf/utils/draft.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ietf/utils/draft.py b/ietf/utils/draft.py index 82fec27f11..d6f96f5e9c 100755 --- a/ietf/utils/draft.py +++ b/ietf/utils/draft.py @@ -203,7 +203,7 @@ def __init__(self, text, source, name_from_source=False): """ super().__init__() assert isinstance(text, str) - self.source = source + self.source = str(source) self.rawtext = text self.name_from_source = name_from_source From 5dbf933f33812497153479eee77773e317d69b4f Mon Sep 17 00:00:00 2001 From: Jennifer Richards Date: Wed, 31 May 2023 16:23:43 -0300 Subject: [PATCH 2/3] fix: Guard against failure to extract PlaintextDraft title --- ietf/submit/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ietf/submit/utils.py b/ietf/submit/utils.py index dfc6f2835b..adab7dc3ae 100644 --- a/ietf/submit/utils.py +++ b/ietf/submit/utils.py @@ -1213,7 +1213,9 @@ def process_submission_text(filename, revision): f"Text Internet-Draft revision ({text_draft.revision}) " f"disagrees with submission revision ({revision})" ) - title = _normalize_title(text_draft.get_title()) + title = text_draft.get_title() + if title: + title = _normalize_title(title) if not title: # This test doesn't work well - the text_draft parser tends to grab "Abstract" as # the title if there's an empty title. From bf3229b2592d9d9bd14fc76df2fbf2a10d3b0edc Mon Sep 17 00:00:00 2001 From: Jennifer Richards Date: Wed, 31 May 2023 17:51:25 -0300 Subject: [PATCH 3/3] fix: Ignore failure to extract text draft title unless it is needed --- ietf/submit/utils.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ietf/submit/utils.py b/ietf/submit/utils.py index adab7dc3ae..3fdecb2d5d 100644 --- a/ietf/submit/utils.py +++ b/ietf/submit/utils.py @@ -1216,10 +1216,6 @@ def process_submission_text(filename, revision): title = text_draft.get_title() if title: title = _normalize_title(title) - if not title: - # This test doesn't work well - the text_draft parser tends to grab "Abstract" as - # the title if there's an empty title. - raise SubmissionError("Could not extract a title from the text") # Drops \r, \n, <, >. Based on get_draft_meta() behavior trans_table = str.maketrans("", "", "\r\n<>") @@ -1235,7 +1231,7 @@ def process_submission_text(filename, revision): return { "filename": text_draft.filename, "rev": text_draft.revision, - "title": _normalize_title(text_draft.get_title()), + "title": title, "authors": authors, "abstract": text_draft.get_abstract(), "document_date": text_draft.get_creation_date(), @@ -1288,6 +1284,9 @@ def process_and_validate_submission(submission): submission.title = text_metadata["title"] submission.authors = text_metadata["authors"] + if not submission.title: + raise SubmissionError("Could not determine the title of the draft") + # Items always to get from text, even when XML is available submission.abstract = text_metadata["abstract"] submission.document_date = text_metadata["document_date"]