1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2026-10-28 15:02:28 +00:00

queue: Fix inverted logic in mustIDNAToASCII

In mustIDNAToASCII, we accidentally return the unconverted domain on
success, and the failed conversion on error.

This affects the sender rewriting when forwarding, and can only be
triggered via aliases in local IDN domains.

This patch fixes the problem by adjusting the logic, and adds tests to
prevent future regressions.
This commit is contained in:
Alberto Bertogli
2026-10-08 23:55:05 +01:00
parent 61792e3bb4
commit 46c0644363
2 changed files with 23 additions and 2 deletions
+2 -2
View File
@@ -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 {
+21
View File
@@ -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()