diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2024-04-03 11:58:37 +0200 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2024-04-03 11:17:36 +0000 |
| commit | 0d897526f93c50fc2ebd2b43e686f9cdc446d447 (patch) | |
| tree | bb5bcb632bae8ce1887da3774d5d6e4d10fd6dc7 /pkg/subsystem/linux | |
| parent | eca13509503864c93d589d0a5ee59548ff8280be (diff) | |
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.
Diffstat (limited to 'pkg/subsystem/linux')
| -rw-r--r-- | pkg/subsystem/linux/maintainers.go | 8 |
1 files changed, 6 insertions, 2 deletions
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 |
