From 65119318100915eb99bc726693951a982a3f130a Mon Sep 17 00:00:00 2001 From: Dmitri Shuralyov Date: Wed, 26 Apr 2017 19:07:15 -0400 Subject: [PATCH] cmd/go/internal/get: allow go get on github.com/ import paths with Unicode letters MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit More specifically, allow Unicode letters in the directories of GitHub repositories, which can occur and don't have a valid reason to be disallowed by go get. Do so by using a predefined character class, the Unicode character property class \p{L} that describes the Unicode characters that are letters: http://www.regular-expressions.info/unicode.html#category Since it's not possible to create GitHub usernames or repositories containing Unicode letters at this time, those parts of the import path are still restricted to ASCII letters only. Fix name of tested func in t.Errorf messages. Fixes #18660. Change-Id: Ia0ef4742bfd8317d989ef1eb1d7065e382852fe2 Reviewed-on: https://go-review.googlesource.com/41822 Reviewed-by: Brad Fitzpatrick Reviewed-by: Daniel Martí Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- src/cmd/go/internal/get/vcs.go | 2 +- src/cmd/go/internal/get/vcs_test.go | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/cmd/go/internal/get/vcs.go b/src/cmd/go/internal/get/vcs.go index 7439cc8649..c72d52bc1b 100644 --- a/src/cmd/go/internal/get/vcs.go +++ b/src/cmd/go/internal/get/vcs.go @@ -851,7 +851,7 @@ var vcsPaths = []*vcsPath{ // Github { prefix: "github.com/", - re: `^(?Pgithub\.com/[A-Za-z0-9_.\-]+/[A-Za-z0-9_.\-]+)(/[A-Za-z0-9_.\-]+)*$`, + re: `^(?Pgithub\.com/[A-Za-z0-9_.\-]+/[A-Za-z0-9_.\-]+)(/[\p{L}0-9_.\-]+)*$`, vcs: "git", repo: "https://{root}", check: noVCSSuffix, diff --git a/src/cmd/go/internal/get/vcs_test.go b/src/cmd/go/internal/get/vcs_test.go index f858ee9ddc..62d352ae57 100644 --- a/src/cmd/go/internal/get/vcs_test.go +++ b/src/cmd/go/internal/get/vcs_test.go @@ -32,6 +32,14 @@ func TestRepoRootForImportPath(t *testing.T) { repo: "https://github.com/golang/groupcache", }, }, + // Unicode letters in directories (issue 18660). + { + "github.com/user/unicode/испытание", + &repoRoot{ + vcs: vcsGit, + repo: "https://github.com/user/unicode", + }, + }, // IBM DevOps Services tests { "hub.jazz.net/git/user1/pkgname", @@ -154,16 +162,16 @@ func TestRepoRootForImportPath(t *testing.T) { if want == nil { if err == nil { - t.Errorf("RepoRootForImport(%q): Error expected but not received", test.path) + t.Errorf("repoRootForImportPath(%q): Error expected but not received", test.path) } continue } if err != nil { - t.Errorf("RepoRootForImport(%q): %v", test.path, err) + t.Errorf("repoRootForImportPath(%q): %v", test.path, err) continue } if got.vcs.name != want.vcs.name || got.repo != want.repo { - t.Errorf("RepoRootForImport(%q) = VCS(%s) Repo(%s), want VCS(%s) Repo(%s)", test.path, got.vcs, got.repo, want.vcs, want.repo) + t.Errorf("repoRootForImportPath(%q) = VCS(%s) Repo(%s), want VCS(%s) Repo(%s)", test.path, got.vcs, got.repo, want.vcs, want.repo) } } } -- 2.48.1