From 9325d0dbaa9e2f51adc6c8be49e7f4f4c89f6812 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Sun, 29 Oct 2023 22:45:56 +0300 Subject: [PATCH] Improve data sanitization --- action/auxi.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/action/auxi.go b/action/auxi.go index 6000d3e0..5acb0061 100644 --- a/action/auxi.go +++ b/action/auxi.go @@ -30,7 +30,7 @@ type OutputContainer struct { // ////////////////////////////////////////////////////////////////////////////////// // // escapeCharRegex is regexp for searching escape characters -var escapeCharRegex = regexp.MustCompile(`\x1b\[[0-9\;]+m`) +var escapeCharRegex = regexp.MustCompile("[\u001B\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\u0007)|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))") // ////////////////////////////////////////////////////////////////////////////////// // @@ -156,5 +156,6 @@ func fmtValue(v string) string { // sanitizeData removes escape characters func sanitizeData(data []byte) []byte { + data = bytes.ReplaceAll(data, []byte("\r"), nil) return escapeCharRegex.ReplaceAll(data, nil) }