1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-17 14:37:02 +00:00

Normalize domains

We should ignore the domains' case, and treat them uniformly, specially when it
comes to local domains.

This patch extends the existing normalization (IDNA, keeping domains as
UTF8 internally) to include case conversion and NFC form for
consistency.
This commit is contained in:
Alberto Bertogli
2016-10-09 16:05:25 +01:00
parent ad25706d72
commit 112e492c3a
7 changed files with 102 additions and 41 deletions

View File

@@ -8,8 +8,6 @@ import (
"strings"
"time"
"golang.org/x/net/idna"
"blitiri.com.ar/go/chasquid/internal/normalize"
"blitiri.com.ar/go/chasquid/internal/userdb"
)
@@ -77,12 +75,13 @@ func DecodeResponse(response string) (user, domain, passwd string, err error) {
// Normalize the user and domain. This is so users can write the username
// in their own style and still can log in. For the domain, we use IDNA
// to turn it to utf8 which is what we use internally.
// and relevant transformations to turn it to utf8 which is what we use
// internally.
user, err = normalize.User(user)
if err != nil {
return
}
domain, err = idna.ToUnicode(domain)
domain, err = normalize.Domain(domain)
if err != nil {
return
}