mirror of
				https://git.anonymousland.org/anonymousland/synapse.git
				synced 2025-11-03 22:24:07 -05:00 
			
		
		
		
	Linkify plain text messages too
This commit is contained in:
		
							parent
							
								
									424a7f48f8
								
							
						
					
					
						commit
						9dba1b668c
					
				
					 1 changed files with 12 additions and 1 deletions
				
			
		| 
						 | 
					@ -219,7 +219,7 @@ class Mailer(object):
 | 
				
			||||||
        if msgformat == "org.matrix.custom.html":
 | 
					        if msgformat == "org.matrix.custom.html":
 | 
				
			||||||
            ret["body_text_html"] = safe_markup(event.content["formatted_body"])
 | 
					            ret["body_text_html"] = safe_markup(event.content["formatted_body"])
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            ret["body_text_plain"] = event.content["body"]
 | 
					            ret["body_text_html"] = safe_text(event.content["body"])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return ret
 | 
					        return ret
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -301,6 +301,17 @@ def safe_markup(raw_html):
 | 
				
			||||||
    )))
 | 
					    )))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def safe_text(raw_text):
 | 
				
			||||||
 | 
					    """
 | 
				
			||||||
 | 
					    Process text: treat it as HTML but escape any tags (ie. just escape the
 | 
				
			||||||
 | 
					    HTML) then linkify it.
 | 
				
			||||||
 | 
					    """
 | 
				
			||||||
 | 
					    return jinja2.Markup(bleach.linkify(bleach.clean(
 | 
				
			||||||
 | 
					        raw_text, tags=[], attributes={},
 | 
				
			||||||
 | 
					        strip=False
 | 
				
			||||||
 | 
					    )))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def deduped_ordered_list(l):
 | 
					def deduped_ordered_list(l):
 | 
				
			||||||
    seen = set()
 | 
					    seen = set()
 | 
				
			||||||
    ret = []
 | 
					    ret = []
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue