Skip to content

Commit

Permalink
Fix OOB error and improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulSonOfLars committed Jan 6, 2024
1 parent 51ad059 commit 0099e0e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion md2htmlV2.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func (cv ConverterV2) md2html(in []rune, enableButtons bool) (string, []ButtonV2
return out.String() + "<" + chars[item] + ">" + nestedT + "</" + closeSpans(chars[item]) + ">" + followT, append(nestedB, followB...)

case '&':
if !(i+3 < len(in) && in[i+1] == 'g' && in[i+2] == 't' && in[i+3] == ';') {
if !(i+4 < len(in) && in[i+1] == 'g' && in[i+2] == 't' && in[i+3] == ';') {
out.WriteRune(c)
continue
}
Expand Down
3 changes: 3 additions & 0 deletions md2htmlV2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ func TestNotMD2HTMLV2(t *testing.T) {
}, {
in: "|noop|",
out: "|noop|",
}, {
in: "end with >",
out: "end with &gt;",
}, {
in: "no premium ! in text", // confirm that a '!' doesnt break premiums
out: "no premium ! in text",
Expand Down
4 changes: 3 additions & 1 deletion reverseV2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ func TestReverseV2(t *testing.T) {
for _, test := range []string{
"___________test_______",
"|||||spoiler|||",
`![👍](tg://emoji?id=5368324170671202286)`,
"![👍](tg://emoji?id=5368324170671202286)",
">",
"test\n>\ntest",
} {
out, err := tg_md2html.ReverseV2(tg_md2html.MD2HTMLV2(test), nil)
assert.NoError(t, err, "Error for:\n%s", test)
Expand Down

0 comments on commit 0099e0e

Please sign in to comment.