Skip to content

txtar: add CRLF handling #435

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
* simplifications (comments #150, #155)
  • Loading branch information
bsponge committed Sep 30, 2023
commit 5b9bb80a85e341458723fde89183552040f2a4c3
4 changes: 2 additions & 2 deletions txtar/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,11 @@ func isMarker(data []byte) (name string, lineSeparator, after []byte) {
// lineSeparator states if \n or \r\n should be appended as a line separator if it is not present.
// Otherwise fixNL returns a new slice consisting of data with a final lineSeparator added.
func fixNL(data , lineSeparator []byte) []byte {
if len(data) == 0 || bytes.HasSuffix(data, lf) || bytes.HasSuffix(data, crlf) {
if len(data) == 0 || bytes.HasSuffix(data, lf) {
return data
}
d := make([]byte, len(data)+len(lineSeparator))
copy(d, data)
copy(d[len(d)-len(lineSeparator):], lineSeparator)
copy(d[len(data):], lineSeparator)
return d
}