You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
	
	
		
			27 lines
		
	
	
		
			659 B
		
	
	
	
		
			TypeScript
		
	
		
		
			
		
	
	
			27 lines
		
	
	
		
			659 B
		
	
	
	
		
			TypeScript
		
	
| 
											6 years ago
										 | import React from 'react'; | ||
|  | import DOMPurify from 'dompurify'; | ||
|  | 
 | ||
|  | interface ReceivedProps { | ||
|  |   html: string; | ||
|  |   tag?: string; | ||
|  |   key?: any; | ||
| 
											5 years ago
										 |   className?: string; | ||
| 
											6 years ago
										 | } | ||
|  | 
 | ||
| 
											6 years ago
										 | // Needed because of https://github.com/microsoft/tslint-microsoft-contrib/issues/339
 | ||
| 
											6 years ago
										 | type Props = ReceivedProps; | ||
|  | 
 | ||
| 
											5 years ago
										 | export const SessionHtmlRenderer: React.SFC<Props> = ({ tag = 'div', key, html, className }) => { | ||
| 
											6 years ago
										 |   const clean = DOMPurify.sanitize(html, { | ||
|  |     USE_PROFILES: { html: true }, | ||
| 
											5 years ago
										 |     FORBID_ATTR: ['script'], | ||
| 
											6 years ago
										 |   }); | ||
|  | 
 | ||
|  |   return React.createElement(tag, { | ||
|  |     key, | ||
| 
											5 years ago
										 |     className, | ||
| 
											4 years ago
										 |     // tslint:disable-next-line: react-no-dangerous-html
 | ||
| 
											6 years ago
										 |     dangerouslySetInnerHTML: { __html: clean }, | ||
|  |   }); | ||
|  | }; |