mirror of
				https://codeberg.org/forgejo/forgejo.git
				synced 2025-10-30 22:11:07 +00:00 
			
		
		
		
	add regexp to restrict <code class=""></code>
		
	This commit is contained in:
		
					parent
					
						
							
								357c002c03
							
						
					
				
			
			
				commit
				
					
						e4d4662074
					
				
			
		
					 1 changed files with 2 additions and 4 deletions
				
			
		|  | @ -15,6 +15,7 @@ import ( | |||
| 	"hash" | ||||
| 	"html/template" | ||||
| 	"math" | ||||
| 	"regexp" | ||||
| 	"strings" | ||||
| 	"time" | ||||
| 
 | ||||
|  | @ -26,11 +27,8 @@ import ( | |||
| 	"github.com/gogits/gogs/modules/setting" | ||||
| ) | ||||
| 
 | ||||
| var Sanitizer = bluemonday.UGCPolicy() | ||||
| var Sanitizer = bluemonday.UGCPolicy().AllowAttrs("class").Matching(regexp.MustCompile(`[\p{L}\p{N}\s\-_',:\[\]!\./\\\(\)&]*`)).OnElements("code") | ||||
| 
 | ||||
| func init() { | ||||
| 	Sanitizer.AllowAttrs("class").OnElements("code") | ||||
| } | ||||
| 
 | ||||
| // Encode string to md5 hex value. | ||||
| func EncodeMd5(str string) string { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue