@@ -226,23 +226,30 @@ def urlize_ietf_docs(string, autoescape=None):
226226 """
227227 if autoescape and not isinstance (string , SafeData ):
228228 string = escape (string )
229- string = re .sub (r"(?<!>)(RFC\s*?)0{0,3}(\d+)" , "<a href=\" /doc/rfc\\ 2/\" >\\ 1\\ 2</a>" , string , flags = re .IGNORECASE )
230- string = re .sub (r"(?<!>)(BCP\s*?)0{0,3}(\d+)" , "<a href=\" /doc/bcp\\ 2/\" >\\ 1\\ 2</a>" , string , flags = re .IGNORECASE )
231- string = re .sub (r"(?<!>)(STD\s*?)0{0,3}(\d+)" , "<a href=\" /doc/std\\ 2/\" >\\ 1\\ 2</a>" , string , flags = re .IGNORECASE )
232- string = re .sub (r"(?<!>)(FYI\s*?)0{0,3}(\d+)" , "<a href=\" /doc/fyi\\ 2/\" >\\ 1\\ 2</a>" , string , flags = re .IGNORECASE )
233- string = re .sub (r"(?<!>)(draft-[-0-9a-zA-Z._+]+)" , "<a href=\" /doc/\\ 1/\" >\\ 1</a>" , string , flags = re .IGNORECASE )
234- string = re .sub (r"(?<!>)(conflict-review-[-0-9a-zA-Z._+]+)" , "<a href=\" /doc/\\ 1/\" >\\ 1</a>" , string , flags = re .IGNORECASE )
235- string = re .sub (r"(?<!>)(status-change-[-0-9a-zA-Z._+]+)" , "<a href=\" /doc/\\ 1/\" >\\ 1</a>" , string , flags = re .IGNORECASE )
229+ string = re .sub (r"(RFC\s*?)0{0,3}(\d+)" , "<a href=\" /doc/rfc\\ 2/\" >\\ 1\\ 2</a>" , string , flags = re .IGNORECASE )
230+ string = re .sub (r"(BCP\s*?)0{0,3}(\d+)" , "<a href=\" /doc/bcp\\ 2/\" >\\ 1\\ 2</a>" , string , flags = re .IGNORECASE )
231+ string = re .sub (r"(STD\s*?)0{0,3}(\d+)" , "<a href=\" /doc/std\\ 2/\" >\\ 1\\ 2</a>" , string , flags = re .IGNORECASE )
232+ string = re .sub (r"(FYI\s*?)0{0,3}(\d+)" , "<a href=\" /doc/fyi\\ 2/\" >\\ 1\\ 2</a>" , string , flags = re .IGNORECASE )
233+ string = re .sub (r"(draft-[-0-9a-zA-Z._+]+)" , "<a href=\" /doc/\\ 1/\" >\\ 1</a>" , string , flags = re .IGNORECASE )
234+ string = re .sub (r"(conflict-review-[-0-9a-zA-Z._+]+)" , "<a href=\" /doc/\\ 1/\" >\\ 1</a>" , string , flags = re .IGNORECASE )
235+ string = re .sub (r"(status-change-[-0-9a-zA-Z._+]+)" , "<a href=\" /doc/\\ 1/\" >\\ 1</a>" , string , flags = re .IGNORECASE )
236+ string = re .sub (r"(charter-[-0-9a-zA-Z._+]+)" , "<a href=\" /doc/\\ 1/\" >\\ 1</a>" , string , flags = re .IGNORECASE )
236237 return mark_safe (string )
237238urlize_ietf_docs = stringfilter (urlize_ietf_docs )
238239
239240@register .filter (name = 'urlize_related_source_list' , is_safe = True , needs_autoescape = True )
240241def urlize_related_source_list (related , autoescape = None ):
241242 """Convert a list of DocumentRelations into list of links using the source document's canonical name"""
242243 links = []
244+ names = set ()
245+ titles = set ()
243246 for rel in related :
244247 name = rel .source .canonical_name ()
245248 title = rel .source .title
249+ if name in names and title in titles :
250+ continue
251+ names .add (name )
252+ titles .add (title )
246253 url = urlreverse ('ietf.doc.views_doc.document_main' , kwargs = dict (name = name ))
247254 if autoescape :
248255 name = escape (name )
@@ -409,7 +416,9 @@ def ad_area(user):
409416def format_history_text (text , trunc_words = 25 ):
410417 """Run history text through some cleaning and add ellipsis if it's too long."""
411418 full = mark_safe (text )
412- full = urlize_ietf_docs (full )
419+ if "</a>" not in full :
420+ full = urlize_ietf_docs (full )
421+ full = bleach .linkify (full , parse_email = True )
413422
414423 return format_snippet (full , trunc_words )
415424
0 commit comments