From f17777995b0383432ff360690dceb6fb6bdb6c85 Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Wed, 19 Jun 2019 04:53:15 -0400 Subject: [PATCH 1/5] add a new test --- irc/strings_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/irc/strings_test.go b/irc/strings_test.go index 595ef7f6..40d32f68 100644 --- a/irc/strings_test.go +++ b/irc/strings_test.go @@ -189,6 +189,10 @@ func TestSkeleton(t *testing.T) { t.Errorf("we must protect against cyrillic homoglyph attacks") } + if skeleton("еmily") != skeleton("emily") { + t.Errorf("we must protect against cyrillic homoglyph attacks") + } + if skeleton("РОТАТО") != "potato" { t.Errorf("we must protect against cyrillic homoglyph attacks") } From 6e9a31a574efb1669b0acc606222ef7a9a675f55 Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Wed, 19 Jun 2019 04:56:11 -0400 Subject: [PATCH 2/5] use confusables.SkeletonTweaked to fix the test --- Gopkg.lock | 4 ++-- Gopkg.toml | 2 +- irc/strings.go | 24 +----------------------- irc/strings_test.go | 12 ------------ vendor | 2 +- 5 files changed, 5 insertions(+), 39 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index 73ab4a22..a7a47151 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -62,11 +62,11 @@ revision = "9520e82c474b0a04dd04f8a40959027271bab992" [[projects]] - digest = "1:7caf3ea977a13cd8b9a2e1ecef1ccaa8e38f831b4f6ffcb8bd0aa909c48afb3a" + digest = "1:940e48aff4b5fe62c3e6fd1245cc35271327a424b7ffbe4febfa83ff8f9c4f53" name = "github.com/oragono/confusables" packages = ["."] pruneopts = "UT" - revision = "d5dd03409482fae2457f0742be22782890f720c2" + revision = "e65e89839ad43b68dbea2d3ca62f0f1c594b029a" [[projects]] branch = "master" diff --git a/Gopkg.toml b/Gopkg.toml index b4656ed4..ed8deed7 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -50,7 +50,7 @@ name = "github.com/oragono/go-ident" [[constraint]] - revision = "d5dd03409482fae2457f0742be22782890f720c2" + revision = "e65e89839ad43b68dbea2d3ca62f0f1c594b029a" name = "github.com/oragono/confusables" [[constraint]] diff --git a/irc/strings.go b/irc/strings.go index be671164..d0bbf8b1 100644 --- a/irc/strings.go +++ b/irc/strings.go @@ -108,26 +108,6 @@ func CasefoldName(name string) (string, error) { return lowered, err } -// "boring" names are exempt from skeletonization. -// this is because confusables.txt considers various pure ASCII alphanumeric -// strings confusable: 0 and O, 1 and l, m and rn. IMO this causes more problems -// than it solves. -func isBoring(name string) bool { - for i := 0; i < len(name); i += 1 { - chr := name[i] - if (chr >= 'a' && chr <= 'z') || (chr >= 'A' && chr <= 'Z') || (chr >= '0' && chr <= '9') { - continue // alphanumerics - } - switch chr { - case '$', '%', '^', '&', '(', ')', '{', '}', '[', ']', '<', '>', '=': - continue // benign printable ascii characters - default: - return false // potentially confusable ascii like | ' `, non-ascii - } - } - return true -} - // returns true if the given name is a valid ident, using a mix of Insp and // Chary's ident restrictions. func isIdent(name string) bool { @@ -168,9 +148,7 @@ func Skeleton(name string) (string, error) { // same as PRECIS: name = width.Fold.String(name) - if !isBoring(name) { - name = confusables.Skeleton(name) - } + name = confusables.SkeletonTweaked(name) // internationalized lowercasing for skeletons; this is much more lenient than // Casefold. In particular, skeletons are expected to mix scripts (which may diff --git a/irc/strings_test.go b/irc/strings_test.go index 40d32f68..b24bf08d 100644 --- a/irc/strings_test.go +++ b/irc/strings_test.go @@ -128,18 +128,6 @@ func TestCasefoldName(t *testing.T) { } } -func TestIsBoring(t *testing.T) { - assertBoring := func(str string, expected bool) { - if isBoring(str) != expected { - t.Errorf("expected [%s] to have boringness [%t], but got [%t]", str, expected, !expected) - } - } - - assertBoring("warning", true) - assertBoring("phi|ip", false) - assertBoring("Νικηφόρος", false) -} - func TestIsIdent(t *testing.T) { assertIdent := func(str string, expected bool) { if isIdent(str) != expected { diff --git a/vendor b/vendor index 8ddbb531..42b0d2d5 160000 --- a/vendor +++ b/vendor @@ -1 +1 @@ -Subproject commit 8ddbb531841add50f8b7aff8fe00bef311448aaa +Subproject commit 42b0d2d5d24a9b0ed4295fa04fd66e7c4ff27fa8 From 990d76923c6f374aadcfb7a50c0183facc748bd3 Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Sun, 23 Jun 2019 15:54:33 -0400 Subject: [PATCH 3/5] bump vendor again --- Gopkg.lock | 4 ++-- Gopkg.toml | 2 +- vendor | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index a7a47151..bf3aa178 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -62,11 +62,11 @@ revision = "9520e82c474b0a04dd04f8a40959027271bab992" [[projects]] - digest = "1:940e48aff4b5fe62c3e6fd1245cc35271327a424b7ffbe4febfa83ff8f9c4f53" + digest = "1:5e7ab79f15b8734a3d7b1fe09e943b4bdd01587006a94a51737d32ac84bb84f3" name = "github.com/oragono/confusables" packages = ["."] pruneopts = "UT" - revision = "e65e89839ad43b68dbea2d3ca62f0f1c594b029a" + revision = "7ad2fd2ae159c35dc6004add297296011e6f2755" [[projects]] branch = "master" diff --git a/Gopkg.toml b/Gopkg.toml index ed8deed7..bdc9e11b 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -50,7 +50,7 @@ name = "github.com/oragono/go-ident" [[constraint]] - revision = "e65e89839ad43b68dbea2d3ca62f0f1c594b029a" + revision = "7ad2fd2ae159c35dc6004add297296011e6f2755" name = "github.com/oragono/confusables" [[constraint]] diff --git a/vendor b/vendor index 42b0d2d5..a46f2f2b 160000 --- a/vendor +++ b/vendor @@ -1 +1 @@ -Subproject commit 42b0d2d5d24a9b0ed4295fa04fd66e7c4ff27fa8 +Subproject commit a46f2f2b67cfbb9974548de5bb58c72306ec861c From b075ea6eb98ac27f95bad3c6a9c49c3b769b37e8 Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Mon, 24 Jun 2019 00:14:39 -0400 Subject: [PATCH 4/5] use regular Skeleton instead of SkeletonTweaked dan: "I probably wouldn't expect those mappings to cause much trouble at all for legitimate users at the end of the day" shivaram: [concurs] --- irc/strings.go | 2 +- irc/strings_test.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/irc/strings.go b/irc/strings.go index d0bbf8b1..c665dca5 100644 --- a/irc/strings.go +++ b/irc/strings.go @@ -148,7 +148,7 @@ func Skeleton(name string) (string, error) { // same as PRECIS: name = width.Fold.String(name) - name = confusables.SkeletonTweaked(name) + name = confusables.Skeleton(name) // internationalized lowercasing for skeletons; this is much more lenient than // Casefold. In particular, skeletons are expected to mix scripts (which may diff --git a/irc/strings_test.go b/irc/strings_test.go index b24bf08d..d1e8b76c 100644 --- a/irc/strings_test.go +++ b/irc/strings_test.go @@ -153,15 +153,15 @@ func TestSkeleton(t *testing.T) { return skel } - if skeleton("warning") == skeleton("waming") { - t.Errorf("Oragono shouldn't consider rn confusable with m") + if skeleton("warning") != skeleton("waming") { + t.Errorf("i give up, Oragono should consider rn confusable with m") } if skeleton("Phi|ip") != "philip" { t.Errorf("but we still consider pipe confusable with l") } - if skeleton("smt") != "smt" { + if skeleton("smt") != skeleton("smt") { t.Errorf("fullwidth characters should skeletonize to plain old ascii characters") } @@ -169,7 +169,7 @@ func TestSkeleton(t *testing.T) { t.Errorf("after skeletonizing, we should casefold") } - if skeleton("smt") != "smt" { + if skeleton("smt") != skeleton("smt") { t.Errorf("our friend lover successfully tricked the skeleton algorithm!") } From 4e9c0fbc00829499ac78c6eec47330856f7e3641 Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Mon, 24 Jun 2019 00:29:44 -0400 Subject: [PATCH 5/5] revert vendor changes --- Gopkg.lock | 4 ++-- Gopkg.toml | 2 +- vendor | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index bf3aa178..73ab4a22 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -62,11 +62,11 @@ revision = "9520e82c474b0a04dd04f8a40959027271bab992" [[projects]] - digest = "1:5e7ab79f15b8734a3d7b1fe09e943b4bdd01587006a94a51737d32ac84bb84f3" + digest = "1:7caf3ea977a13cd8b9a2e1ecef1ccaa8e38f831b4f6ffcb8bd0aa909c48afb3a" name = "github.com/oragono/confusables" packages = ["."] pruneopts = "UT" - revision = "7ad2fd2ae159c35dc6004add297296011e6f2755" + revision = "d5dd03409482fae2457f0742be22782890f720c2" [[projects]] branch = "master" diff --git a/Gopkg.toml b/Gopkg.toml index bdc9e11b..b4656ed4 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -50,7 +50,7 @@ name = "github.com/oragono/go-ident" [[constraint]] - revision = "7ad2fd2ae159c35dc6004add297296011e6f2755" + revision = "d5dd03409482fae2457f0742be22782890f720c2" name = "github.com/oragono/confusables" [[constraint]] diff --git a/vendor b/vendor index a46f2f2b..8ddbb531 160000 --- a/vendor +++ b/vendor @@ -1 +1 @@ -Subproject commit a46f2f2b67cfbb9974548de5bb58c72306ec861c +Subproject commit 8ddbb531841add50f8b7aff8fe00bef311448aaa