6666from ietf .review .models import ReviewRequest
6767from ietf .review .utils import can_request_review_of_doc , review_requests_to_list_for_docs
6868from ietf .review .utils import no_review_from_teams_on_doc
69+ from ietf .utils import markup_txt , log
70+ from ietf .utils .text import maybe_split
6971
7072
7173def render_document_top (request , doc , tab , name ):
@@ -186,7 +188,13 @@ def document_main(request, name, rev=None):
186188 filename = name + ".txt"
187189
188190 content = get_document_content (filename , os .path .join (settings .RFC_PATH , filename ),
189- split_content , markup = True )
191+ split_content , markup = True ).decode ('utf-8' )
192+ utext = doc .text_or_error () # pyflakes:ignore
193+ if content and content != utext and not 'Error; cannot read' in content :
194+ debug .show ('content[:64]' )
195+ debug .show ('utext[:64]' )
196+ log .assertion ('content == utext' )
197+ content = markup_txt .markup (maybe_split (content , split = split_content ))
190198
191199 # file types
192200 base_path = os .path .join (settings .RFC_PATH , name + "." )
@@ -216,7 +224,13 @@ def document_main(request, name, rev=None):
216224 filename = "%s-%s.txt" % (draft_name , doc .rev )
217225
218226 content = get_document_content (filename , os .path .join (settings .INTERNET_ALL_DRAFTS_ARCHIVE_DIR , filename ),
219- split_content , markup = True )
227+ split_content , markup = True ).decode ('utf-8' )
228+ utext = doc .text_or_error () # pyflakes:ignore
229+ if content and content != utext and not 'Error; cannot read' in content :
230+ debug .show ('content[:64]' )
231+ debug .show ('utext[:64]' )
232+ log .assertion ('content == utext' )
233+ content = markup_txt .markup (maybe_split (content , split = split_content ))
220234
221235 # file types
222236 base_path = os .path .join (settings .INTERNET_DRAFT_PATH , doc .name + "-" + doc .rev + "." )
@@ -439,7 +453,13 @@ def document_main(request, name, rev=None):
439453 if doc .type_id == "charter" :
440454 filename = "%s-%s.txt" % (doc .canonical_name (), doc .rev )
441455
442- content = get_document_content (filename , os .path .join (settings .CHARTER_PATH , filename ), split = False , markup = True )
456+ content = get_document_content (filename , os .path .join (settings .CHARTER_PATH , filename ), split = False , markup = True ).decode ('utf-8' )
457+ utext = doc .text_or_error () # pyflakes:ignore
458+ if content and content != utext and not 'Error; cannot read' in content :
459+ debug .show ('content[:64]' )
460+ debug .show ('utext[:64]' )
461+ log .assertion ('content == utext' )
462+ content = markup_txt .markup (content )
443463
444464 ballot_summary = None
445465 if doc .get_state_slug () in ("intrev" , "iesgrev" ):
@@ -480,9 +500,15 @@ def document_main(request, name, rev=None):
480500
481501 if doc .rev == "00" and not os .path .isfile (pathname ):
482502 # This could move to a template
483- content = "A conflict review response has not yet been proposed."
503+ content = u "A conflict review response has not yet been proposed."
484504 else :
485- content = get_document_content (filename , pathname , split = False , markup = True )
505+ content = get_document_content (filename , pathname , split = False , markup = True ).decode ('utf-8' )
506+ utext = doc .text_or_error () # pyflakes:ignore
507+ if content and content != utext and not 'Error; cannot read' in content :
508+ debug .show ('content[:64]' )
509+ debug .show ('utext[:64]' )
510+ log .assertion ('content == utext' )
511+ content = markup_txt .markup (content )
486512
487513 ballot_summary = None
488514 if doc .get_state_slug () in ("iesgeval" ) and doc .active_ballot ():
@@ -507,9 +533,14 @@ def document_main(request, name, rev=None):
507533
508534 if doc .rev == "00" and not os .path .isfile (pathname ):
509535 # This could move to a template
510- content = "Status change text has not yet been proposed."
536+ content = u "Status change text has not yet been proposed."
511537 else :
512- content = get_document_content (filename , pathname , split = False )
538+ content = get_document_content (filename , pathname , split = False ).decode ('utf-8' )
539+ utext = doc .text_or_error () # pyflakes:ignore
540+ if content and content != utext and not 'Error; cannot read' in content :
541+ debug .show ('content[:64]' )
542+ debug .show ('utext[:64]' )
543+ log .assertion ('content == utext' )
513544
514545 ballot_summary = None
515546 if doc .get_state_slug () in ("iesgeval" ):
@@ -562,7 +593,12 @@ def document_main(request, name, rev=None):
562593 url = urlbase + extension
563594
564595 if extension == ".txt" :
565- content = get_document_content (basename , pathname + extension , split = False )
596+ content = get_document_content (basename , pathname + extension , split = False ).decode ('utf-8' )
597+ utext = doc .text_or_error () # pyflakes:ignore
598+ if content != utext :
599+ debug .show ('content[:64]' )
600+ debug .show ('utext[:64]' )
601+ log .assertion ('content == utext' )
566602 t = "plain text"
567603
568604 other_types .append ((t , url ))
0 commit comments