Update.
This commit is contained in:
		
							parent
							
								
									1a034041ab
								
							
						
					
					
						commit
						1c71c0016b
					
				@ -67,6 +67,7 @@ class ChannelMessageService(BaseService):
 | 
			
		||||
        )
 | 
			
		||||
        template = self.app.jinja2_env.get_template("message.html")
 | 
			
		||||
        model["html"] = template.render(**context)
 | 
			
		||||
        model["html"] = whitelist_attributes(model["html"])
 | 
			
		||||
        return await super().save(model)
 | 
			
		||||
 | 
			
		||||
    async def offset(self, channel_uid, page=0, timestamp=None, page_size=30):
 | 
			
		||||
 | 
			
		||||
@ -130,7 +130,9 @@ def whitelist_attributes(html):
 | 
			
		||||
    soup = BeautifulSoup(html, 'html.parser')
 | 
			
		||||
 | 
			
		||||
    for tag in soup.find_all():
 | 
			
		||||
        if isinstance(tag, Tag):
 | 
			
		||||
        if hasattr(tag, 'attrs'):
 | 
			
		||||
            if tag.name == 'script':
 | 
			
		||||
                tag.replace_with('')
 | 
			
		||||
            attrs = dict(tag.attrs)
 | 
			
		||||
            for attr in list(attrs):
 | 
			
		||||
                # Check if attribute is in the safe list or is a data-* attribute
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user