fix(color): validate number range

This commit is contained in:
Jan De Dobbeleer 2022-12-06 21:26:05 +01:00 committed by Jan De Dobbeleer
parent 20462aa50f
commit a86ab4f525

View file

@ -81,7 +81,7 @@ func (d *DefaultColors) AnsiColorFromString(colorString string, isBackground boo
}
if !strings.HasPrefix(colorString, "#") {
val, err := strconv.ParseUint(colorString, 10, 64)
if err != nil {
if err != nil || val > 255 {
return emptyAnsiColor
}
c256 := color.C256(uint8(val), isBackground)