Compare commits

...

2 Commits

Author SHA1 Message Date
Tom Boucher
4fd5bea3d2
Merge ea4fe334e6c55b55076925c31277f2b2a372b84a into 23f3556371321faf199866989b906f2ef06a8034 2026-04-03 02:07:37 +00:00
Tom Boucher
ea4fe334e6 fix: split tag values from multiple sources individually
When a file has multiple tag frames mapping to the same logical tag
(e.g. both TXXX:MOOD and TMOO), TagLib merges them into one key with
multiple values. SplitTagValue had a len(values) != 1 guard that
skipped splitting entirely in this case, leaving comma-separated
values unsplit.

Change SplitTagValue to split each value individually regardless of
input count. Empty values are filtered during splitting.

Fixes #5065
2026-03-15 00:59:49 -04:00

View File

@ -34,23 +34,25 @@ type TagConf struct {
SplitRx *regexp.Regexp `yaml:"-"`
}
// SplitTagValue splits a tag value by the split separators, but only if it has a single value.
// SplitTagValue splits tag values by the configured split separators.
// Each value in the input slice is individually split and trimmed.
func (c TagConf) SplitTagValue(values []string) []string {
// If there's not exactly one value or no separators, return early.
if len(values) != 1 || c.SplitRx == nil {
if c.SplitRx == nil || len(values) == 0 {
return values
}
tag := values[0]
// Replace all occurrences of any separator with the zero-width space.
tag = c.SplitRx.ReplaceAllString(tag, consts.Zwsp)
var result []string
for _, tag := range values {
// Replace all occurrences of any separator with the zero-width space.
tag = c.SplitRx.ReplaceAllString(tag, consts.Zwsp)
// Split by the zero-width space and trim each substring.
parts := strings.Split(tag, consts.Zwsp)
for i, part := range parts {
parts[i] = strings.TrimSpace(part)
// Split by the zero-width space and trim each substring.
parts := strings.Split(tag, consts.Zwsp)
for _, part := range parts {
result = append(result, strings.TrimSpace(part))
}
}
return parts
return result
}
type TagType string