Skip to content

Commit

Permalink
fix:连续的两个回车符处理不当,后一个回车符没被过滤掉
Browse files Browse the repository at this point in the history
  • Loading branch information
3th1nk committed Feb 19, 2024
1 parent 0ece4e2 commit 04b6415
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/filter/crlf.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func CrlfFilter(s []byte) []byte {
// 清除\r及其左侧的当前行内容
if index := bytes.LastIndexByte(s[:pos], '\n'); index >= 0 {
length -= dropBytes(s, index+1, pos+1)
pos = index + 2
pos = index + 1
} else {
s = s[pos+1:]
length -= pos + 1
Expand Down
4 changes: 2 additions & 2 deletions pkg/filter/crlf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
)

func Test_carriageReturnFilter(t *testing.T) {
src := []byte{0x32, 0x33, 0x35, 0x0D, 0x0D, 0x0A}
expect := []byte{0x0A}
src := []byte{0x32, 0x0A, 0x33, 0x35, 0x0D, 0x0D, 0x36, 0x0D, 0x0A}
expect := []byte{0x32, 0x0A, 0x36, 0x0A}
dst := CrlfFilter(src)
assert.Equal(t, expect, dst)
}

0 comments on commit 04b6415

Please sign in to comment.