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:
parent
5b4d199442
commit
255c7195d1
2 changed files with 26 additions and 1 deletions
|
|
@ -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
BIN
lns
Binary file not shown.
Loading…
Add table
Reference in a new issue