Skip to content

Commit 8d4780d

Browse files
fix: Ignore failure to extract text draft title unless it is needed (ietf-tools#5730)
* fix: Accept a Path as source for a PlaintextDraft * fix: Guard against failure to extract PlaintextDraft title * fix: Ignore failure to extract text draft title unless it is needed
1 parent 36b847b commit 8d4780d

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

ietf/submit/utils.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,11 +1213,9 @@ def process_submission_text(filename, revision):
12131213
f"Text Internet-Draft revision ({text_draft.revision}) "
12141214
f"disagrees with submission revision ({revision})"
12151215
)
1216-
title = _normalize_title(text_draft.get_title())
1217-
if not title:
1218-
# This test doesn't work well - the text_draft parser tends to grab "Abstract" as
1219-
# the title if there's an empty title.
1220-
raise SubmissionError("Could not extract a title from the text")
1216+
title = text_draft.get_title()
1217+
if title:
1218+
title = _normalize_title(title)
12211219

12221220
# Drops \r, \n, <, >. Based on get_draft_meta() behavior
12231221
trans_table = str.maketrans("", "", "\r\n<>")
@@ -1233,7 +1231,7 @@ def process_submission_text(filename, revision):
12331231
return {
12341232
"filename": text_draft.filename,
12351233
"rev": text_draft.revision,
1236-
"title": _normalize_title(text_draft.get_title()),
1234+
"title": title,
12371235
"authors": authors,
12381236
"abstract": text_draft.get_abstract(),
12391237
"document_date": text_draft.get_creation_date(),
@@ -1286,6 +1284,9 @@ def process_and_validate_submission(submission):
12861284
submission.title = text_metadata["title"]
12871285
submission.authors = text_metadata["authors"]
12881286

1287+
if not submission.title:
1288+
raise SubmissionError("Could not determine the title of the draft")
1289+
12891290
# Items always to get from text, even when XML is available
12901291
submission.abstract = text_metadata["abstract"]
12911292
submission.document_date = text_metadata["document_date"]

ietf/utils/draft.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def __init__(self, text, source, name_from_source=False):
203203
"""
204204
super().__init__()
205205
assert isinstance(text, str)
206-
self.source = source
206+
self.source = str(source)
207207
self.rawtext = text
208208
self.name_from_source = name_from_source
209209

0 commit comments

Comments
 (0)