mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 21:28:11 +09:00 
			
		
		
		
	Prevent panic on fuzzer provided string (#14405)
* Prevent panic on fuzzer provided string The fuzzer has found that providing a <body> tag with an attribute to PostProcess causes a panic. This PR removes any rendered html or body tags from the output. Signed-off-by: Andrew Thornton <art27@cantab.net> * Placate lint * placate lint again Signed-off-by: Andrew Thornton <art27@cantab.net> * minor cleanup Signed-off-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
		| @@ -383,3 +383,28 @@ func TestRender_ShortLinks(t *testing.T) { | ||||
| 		`<p><a href="https://example.org" rel="nofollow">[[foobar]]</a></p>`, | ||||
| 		`<p><a href="https://example.org" rel="nofollow">[[foobar]]</a></p>`) | ||||
| } | ||||
|  | ||||
| func Test_ParseClusterFuzz(t *testing.T) { | ||||
| 	setting.AppURL = AppURL | ||||
| 	setting.AppSubURL = AppSubURL | ||||
|  | ||||
| 	var localMetas = map[string]string{ | ||||
| 		"user": "go-gitea", | ||||
| 		"repo": "gitea", | ||||
| 	} | ||||
|  | ||||
| 	data := "<A><maTH><tr><MN><bodY ÿ><temPlate></template><tH><tr></A><tH><d<bodY " | ||||
|  | ||||
| 	val, err := PostProcess([]byte(data), "https://example.com", localMetas, false) | ||||
|  | ||||
| 	assert.NoError(t, err) | ||||
| 	assert.NotContains(t, string(val), "<html") | ||||
|  | ||||
| 	data = "<!DOCTYPE html>\n<A><maTH><tr><MN><bodY ÿ><temPlate></template><tH><tr></A><tH><d<bodY " | ||||
|  | ||||
| 	val, err = PostProcess([]byte(data), "https://example.com", localMetas, false) | ||||
|  | ||||
| 	assert.NoError(t, err) | ||||
|  | ||||
| 	assert.NotContains(t, string(val), "<html") | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user