Skip to content

Commit

Permalink
Actually saturate SGR params
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-nix committed Sep 28, 2020
1 parent 4a20fca commit 81092c7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ansihtml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func TestConvertToHTML(t *testing.T) {
},
{
desc: "integer overflow saturates",
input: "\x1b[30;48;2;9999999999;9999999999;9999999999mThis is black on white",
input: "\x1b[30;48;2;9999999997;9999999998;9999999999mThis is black on white",
output: `<span style="color:black;background-color:rgb(255,255,255);">This is black on white</span>`,
},
{
Expand Down
3 changes: 2 additions & 1 deletion html.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,9 @@ func (w *htmlWriter) handleEscape(finalByte byte, intermediateBytes, parameterBy
// saturate to LONG_MAX
if param >= 214748365 || (param == 214748364 && b >= '8') {
param = 2147483647
} else {
param = param*10 + int(b-'0')
}
param = param*10 + int(b-'0')
} else if b == 'm' {
w.applyEffect(param)
break
Expand Down

0 comments on commit 81092c7

Please sign in to comment.