Skip to content

Commit

Permalink
fix: robust handling of whitespace in license files
Browse files Browse the repository at this point in the history
  • Loading branch information
ed382 authored and ezekg committed Jul 1, 2024
1 parent 335b411 commit 24693f3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions license_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,12 @@ func (lic *LicenseFile) Decrypt(key string) (*LicenseFileDataset, error) {
}

func (lic *LicenseFile) certificate() (*certificate, error) {
payload := lic.Certificate
payload := strings.TrimSpace(lic.Certificate)

// Remove header and footer
payload = strings.TrimPrefix(payload, "-----BEGIN LICENSE FILE-----\n")
payload = strings.TrimSuffix(payload, "-----END LICENSE FILE-----\n")
payload = strings.TrimPrefix(payload, "-----BEGIN LICENSE FILE-----")
payload = strings.TrimSuffix(payload, "-----END LICENSE FILE-----")
payload = strings.TrimSpace(payload)

// Decode
dec, err := base64.StdEncoding.DecodeString(payload)
Expand Down

0 comments on commit 24693f3

Please sign in to comment.