summaryrefslogtreecommitdiffstats
path: root/modules/charset/escape_test.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2022-02-19 15:25:31 +0000
committerGitHub <noreply@github.com>2022-02-19 15:25:31 +0000
commit4b3ebda0e78983682003e027a2da46d38f3ef76c (patch)
tree109cec0b0bbd681b679730827039748793b5f58c /modules/charset/escape_test.go
parent931c2f40e7f7c7698956adecf14814dc0559f801 (diff)
downloadgitea-4b3ebda0e78983682003e027a2da46d38f3ef76c.tar.gz
gitea-4b3ebda0e78983682003e027a2da46d38f3ef76c.zip
Fix panic in EscapeReader (#18820)
There is a potential panic due to a mistaken resetting of the length parameter when multibyte characters go over a read boundary. Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'modules/charset/escape_test.go')
-rw-r--r--modules/charset/escape_test.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/modules/charset/escape_test.go b/modules/charset/escape_test.go
index dec92b4992..1804381413 100644
--- a/modules/charset/escape_test.go
+++ b/modules/charset/escape_test.go
@@ -200,3 +200,12 @@ func TestEscapeControlReader(t *testing.T) {
})
}
}
+
+func TestEscapeControlReader_panic(t *testing.T) {
+ bs := make([]byte, 0, 20479)
+ bs = append(bs, 'A')
+ for i := 0; i < 6826; i++ {
+ bs = append(bs, []byte("—")...)
+ }
+ _, _ = EscapeControlBytes(bs)
+}