Skip to content

Commit

Permalink
Improve data sanitization
Browse files Browse the repository at this point in the history
  • Loading branch information
andyone committed Oct 29, 2023
1 parent 9be2f8e commit 9325d0d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion action/auxi.go
Original file line number Diff line number Diff line change
Expand Up @@ -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=><~]))")

// ////////////////////////////////////////////////////////////////////////////////// //

Expand Down Expand Up @@ -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)
}

0 comments on commit 9325d0d

Please sign in to comment.