fix: zonefinder used a quoted version of %s, but we should use %q instead

change: test message to fit %q

Signed-off-by: Sandor Szuecs <sandor.szuecs@zalando.de>
This commit is contained in:
Sandor Szuecs 2025-06-29 12:12:22 +02:00
parent 2d898cd88d
commit fd5e11764b
No known key found for this signature in database
GPG Key ID: 88AE151C28BECE6B
2 changed files with 6 additions and 6 deletions

View File

@ -43,19 +43,19 @@ func (z ZoneIDName) Add(zoneID, zoneName string) {
// ensures compatibility with such use cases. // ensures compatibility with such use cases.
func (z ZoneIDName) FindZone(hostname string) (suitableZoneID, suitableZoneName string) { func (z ZoneIDName) FindZone(hostname string) (suitableZoneID, suitableZoneName string) {
var name string var name string
domain_labels := strings.Split(hostname, ".") domainLabels := strings.Split(hostname, ".")
for i, label := range domain_labels { for i, label := range domainLabels {
if strings.Contains(label, "_") { if strings.Contains(label, "_") {
continue continue
} }
convertedLabel, err := idna.Lookup.ToUnicode(label) convertedLabel, err := idna.Lookup.ToUnicode(label)
if err != nil { if err != nil {
log.Warnf("Failed to convert label '%s' of hostname '%s' to its Unicode form: %v", label, hostname, err) log.Warnf("Failed to convert label %q of hostname %q to its Unicode form: %v", label, hostname, err)
convertedLabel = label convertedLabel = label
} }
domain_labels[i] = convertedLabel domainLabels[i] = convertedLabel
} }
name = strings.Join(domain_labels, ".") name = strings.Join(domainLabels, ".")
for zoneID, zoneName := range z { for zoneID, zoneName := range z {
if name == zoneName || strings.HasSuffix(name, "."+zoneName) { if name == zoneName || strings.HasSuffix(name, "."+zoneName) {

View File

@ -80,5 +80,5 @@ func TestZoneIDName(t *testing.T) {
hook := testutils.LogsUnderTestWithLogLevel(log.WarnLevel, t) hook := testutils.LogsUnderTestWithLogLevel(log.WarnLevel, t)
_, _ = z.FindZone("???") _, _ = z.FindZone("???")
testutils.TestHelperLogContains("Failed to convert label '???' of hostname '???' to its Unicode form: idna: disallowed rune U+003F", hook, t) testutils.TestHelperLogContains("Failed to convert label \"???\" of hostname \"???\" to its Unicode form: idna: disallowed rune U+003F", hook, t)
} }