Drop regex for canonicalization (#102)

* Drop regex for canonicalization

* Fix CI
This commit is contained in:
wussler 2020-12-01 18:09:25 +01:00 committed by GitHub
parent 5b1a42c2cd
commit 385e6d21d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 19 additions and 19 deletions

View file

@ -2,16 +2,19 @@
package internal
import (
"regexp"
"strings"
"github.com/ProtonMail/gopenpgp/v2/constants"
)
// TrimWhitespace removes whitespace from the end of each line of the input
// string.
func TrimWhitespace(input string) string {
var re = regexp.MustCompile(`(?m)[ \t]*$`)
return re.ReplaceAllString(input, "")
func CanonicalizeAndTrim(text string) string {
lines := strings.Split(text, "\n")
for i := range lines {
lines[i] = strings.TrimRight(lines[i], " \t\r")
}
return strings.Join(lines, "\r\n")
}
// CreationTimeOffset stores the amount of seconds that a signature may be