Skip to content
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

parse checksum even when no EOL is found (#285) #376

Open
wants to merge 1 commit into
base: v2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 4 additions & 1 deletion checksum.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,10 @@ func (c *Client) checksumFromFile(ctx context.Context, checksumURL string, check
return nil, fmt.Errorf(
"Error reading checksum file: %s", err)
}
break
if line == "" {
break
}
// parse the line, if we hit EOF, but the line is not empty
}
checksum, err := parseChecksumLine(line)
if err != nil || checksum == nil {
Expand Down
7 changes: 6 additions & 1 deletion get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -570,13 +570,18 @@ func TestGetFile_checksum_from_file(t *testing.T) {
true,
false,
},

// sha512
{
"?checksum=file:" + checksums + "/CHECKSUM_sha256_gpg",
true,
false,
},
{
// checksum file does not have EOL, ends line with EOF
"?checksum=file:" + httpChecksums.URL + "/sha512-p-EOF.sum",
true,
false,
},
}

for _, tc := range cases {
Expand Down
1 change: 1 addition & 0 deletions testdata/checksum-file/sha512-p-EOF.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
060a8cc41c501e41b4537029661090597aeb4366702ac3cae8959f24b2c49005d6bd339833ebbeb481b127ac822d70b937c1637c8d0eaf81b6979d4c1d75d0e1