fix(lns): pipe separator for dns= records, backwards-compatible with comma

- splitPipe() for new format (pipe-separated records)
- Falls back to splitComma() for legacy comma-separated records
- Prevents comma-in-TXT-value parsing bug

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Claude 2026-04-04 03:17:10 +01:00
parent 5b4d199442
commit 255c7195d1
No known key found for this signature in database
GPG key ID: AF404715446AEB41
2 changed files with 26 additions and 1 deletions

View file

@ -110,7 +110,13 @@ func ParseDNSFromComment(comment string) *NameRecord {
}
record := &NameRecord{}
entries := splitComma(dnsField)
// Split on pipe (preferred) or fall back to comma (legacy)
var entries []string
if core.Contains(dnsField, "|") {
entries = splitPipe(dnsField)
} else {
entries = splitComma(dnsField)
}
for _, entry := range entries {
parts := splitColon(entry, 3)
if len(parts) < 3 {
@ -137,6 +143,25 @@ func ParseDNSFromComment(comment string) *NameRecord {
return record
}
func splitPipe(input string) []string {
parts := make([]string, 0)
current := ""
for _, character := range input {
if character == '|' {
if current != "" {
parts = append(parts, current)
}
current = ""
} else {
current += string(character)
}
}
if current != "" {
parts = append(parts, current)
}
return parts
}
func splitComma(input string) []string {
parts := make([]string, 0)
current := ""

BIN
lns

Binary file not shown.