From 0d897526f93c50fc2ebd2b43e686f9cdc446d447 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Wed, 3 Apr 2024 11:58:37 +0200 Subject: pkg/subsystem: make M parsing more robust There are cases of very long names that make it too hard for the golang library to properly parse the address. --- pkg/subsystem/linux/maintainers.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'pkg/subsystem') diff --git a/pkg/subsystem/linux/maintainers.go b/pkg/subsystem/linux/maintainers.go index 76b2232a6..d1d65400d 100644 --- a/pkg/subsystem/linux/maintainers.go +++ b/pkg/subsystem/linux/maintainers.go @@ -140,10 +140,14 @@ func applyProperty(record *maintainersRecord, property *recordProperty) error { func parseEmail(value string) (string, error) { // Sometimes there happen extra symbols at the end of the line, // let's make this parser more error tolerant. - pos := strings.LastIndexAny(value, ">)") - if pos >= 0 { + if pos := strings.LastIndexAny(value, ">)"); pos >= 0 { value = value[:pos+1] } + // Let's also make the parser more robust by skipping everything before the first <, + // if it exists. + if pos := strings.LastIndexAny(value, "<"); pos >= 0 { + value = value[pos:] + } addr, err := mail.ParseAddress(value) if err != nil { return "", err -- cgit mrf-deployment