aboutsummaryrefslogtreecommitdiffstats
path: root/modules/markup/html_test.go
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2021-01-20 19:47:30 +0100
committerGitHub <noreply@github.com>2021-01-20 20:47:30 +0200
commitfb274ec54b56d0126bdde024d5316309c83fcc0b (patch)
tree4203adad32eb0a8acb1b0efc889e316475d7b0d6 /modules/markup/html_test.go
parent0c3f95034a91a448ae0d96d88a0d8b0f53a9b4a7 (diff)
downloadgitea-fb274ec54b56d0126bdde024d5316309c83fcc0b.tar.gz
gitea-fb274ec54b56d0126bdde024d5316309c83fcc0b.zip
Prevent panic on fuzzer provided string (#14405) (#14409)
* 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> Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'modules/markup/html_test.go')
-rw-r--r--modules/markup/html_test.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/modules/markup/html_test.go b/modules/markup/html_test.go
index b04781489a..a78b936f87 100644
--- a/modules/markup/html_test.go
+++ b/modules/markup/html_test.go
@@ -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")
+}