| author | Alberto Bertogli
<albertito@blitiri.com.ar> 2026-10-08 22:55:05 UTC |
| committer | Alberto Bertogli
<albertito@blitiri.com.ar> 2026-10-08 23:02:13 UTC |
| parent | 61792e3bb46d9b4692e7c5061346b3c4d1676b34 |
| internal/queue/queue.go | +2 | -2 |
| internal/queue/queue_test.go | +21 | -0 |
diff --git a/internal/queue/queue.go b/internal/queue/queue.go index 238cd2a..d22fd56 100644 --- a/internal/queue/queue.go +++ b/internal/queue/queue.go @@ -524,9 +524,9 @@ func nextDelay(createdAt time.Time) time.Duration { func mustIDNAToASCII(s string) string { a, err := idna.ToASCII(s) if err != nil { - return a + return s } - return s + return a } func timeFromProto(ts *Timestamp) time.Time { diff --git a/internal/queue/queue_test.go b/internal/queue/queue_test.go index 4ca3870..0a657c6 100644 --- a/internal/queue/queue_test.go +++ b/internal/queue/queue_test.go @@ -201,6 +201,27 @@ func TestAliases(t *testing.T) { }) } +func TestRewriteSender(t *testing.T) { + cases := []struct { + from, originalAddr, expected string + }{ + {"from@rana", "remote@loco", "remote+fwd_from=from=rana@loco"}, + + // The domain of the original address is converted to ASCII. + {"from@rana", "remote@ñoño", "remote+fwd_from=from=rana@xn--oo-yjab"}, + + // If the conversion fails, the domain is left as-is. + {"from@rana", "remote@xn---", "remote+fwd_from=from=rana@xn---"}, + } + for _, c := range cases { + got := rewriteSender(c.from, c.originalAddr) + if got != c.expected { + t.Errorf("rewriteSender(%q, %q) = %q, expected %q", + c.from, c.originalAddr, got, c.expected) + } + } +} + func TestFullQueue(t *testing.T) { synctest.Test(t, func(t *testing.T) { dir := t.ArtifactDir()