Keep accented letters in AS names (closes #165)
check / check (push) Canceled after 0s

The built-in AS list had no letter outside ASCII, and make asupdate
rejected today's as.csv, which added a country code column.

The generator now checks only the first three header columns and reads
past the rest; the parsing moved into parseCSV. The list is regenerated.
The new source spells some names differently and no longer lists AS 0
or the documentation AS numbers, so the tests that relied on those
entries changed.

A WHOIS answer that is not valid UTF-8 is now decoded as Latin-1, which
RIPE and APNIC send, before it is parsed and stored. LACNIC answers in
UTF-8.

Model: opus-5-5
This commit was merged in pull request #172.
This commit is contained in:
2026-10-27 01:50:34 +01:00
parent 86e1f20e11
commit 6d55d39737
11 changed files with 224 additions and 109 deletions
Binary file not shown.
+13 -9
View File
@@ -22,7 +22,7 @@ func TestGet(t *testing.T) {
name: "AS1 Level 3",
asn: 1,
wantOK: true,
wantDesc: "Level 3 Parent, LLC",
wantDesc: "Level 3 Parent LLC",
},
{
name: "AS15169 Google",
@@ -36,10 +36,10 @@ func TestGet(t *testing.T) {
wantOK: false,
},
{
name: "AS0 IANA Reserved",
asn: 0,
name: "AS1251 with accented letters",
asn: 1251,
wantOK: true,
wantDesc: "Internet Assigned Numbers Authority",
wantDesc: "FUNDAÇÃO DE AMPARO À PESQUISA DO ESTADO SÃO PAULO",
},
}
@@ -69,7 +69,7 @@ func TestGetDescription(t *testing.T) {
asn int
want string
}{
{1, "Level 3 Parent, LLC"},
{1, "Level 3 Parent LLC"},
{999999999, ""},
}
@@ -92,8 +92,7 @@ func TestGetHandle(t *testing.T) {
asn int
want string
}{
{1, "LVLT"},
{0, "IANA-RSVD"},
{1, "LVLT-1"},
{999999999, ""},
}
@@ -142,6 +141,11 @@ func TestSearch(t *testing.T) {
query: "University",
wantMin: 10,
},
{
name: "Search for São Paulo",
query: "São Paulo",
wantMin: 1,
},
{
name: "Non-existent org",
query: "XYZABC123456",
@@ -189,13 +193,13 @@ func TestSearchEmptyQueryMatchesNothing(t *testing.T) {
func TestSearchIgnoresCase(t *testing.T) {
t.Parallel()
const cloudflareASN = 13335 // handle CLOUDFLARENET, "Cloudflare, Inc."
const cloudflareASN = 13335 // handle CLOUDFLARENET, "Cloudflare Inc."
isCloudflare := func(info asinfo.Info) bool {
return info.ASN == cloudflareASN
}
for _, query := range []string{"cloudflarenet", "CLOUDFLARE, INC."} {
for _, query := range []string{"cloudflarenet", "CLOUDFLARE INC."} {
results, _ := asinfo.Search(query, asinfo.Total())
if !slices.ContainsFunc(results, isCloudflare) {
t.Errorf("Search(%q) did not find AS%d", query, cloudflareASN)
+1 -1
View File
@@ -17,7 +17,7 @@ func ExampleGet() {
func ExampleGetDescription() {
desc := asinfo.GetDescription(13335)
fmt.Println(desc)
// Output: Cloudflare, Inc.
// Output: Cloudflare Inc.
}
func ExampleSearch() {