diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource.java index 7e1d00f1f..530dae533 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource.java @@ -151,7 +151,7 @@ public class GitHubSCMSource extends AbstractGitSCMSource { public static final String VALID_GITHUB_REPO_NAME = "^[0-9A-Za-z._-]+$"; public static final String VALID_GITHUB_USER_NAME = - "^(?=[A-Za-z0-9-_]{1,39}$)([A-Za-z0-9]((?:[A-Za-z0-9]+|-(?=[A-Za-z0-9]+))*)(_(?:[A-Za-z0-9]+))?)"; + "^(?=[A-Za-z0-9-_.]{1,39}$)([A-Za-z0-9]((?:[A-Za-z0-9]+|[-.](?=[A-Za-z0-9]+))*)(_(?:[A-Za-z0-9]+))?)"; public static final String VALID_GIT_SHA1 = "^[a-fA-F0-9]{40}$"; public static final String GITHUB_URL = GitHubServerConfig.GITHUB_URL; public static final String GITHUB_COM = "github.com"; diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceTest.java index 1a58db43e..17ed54257 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceTest.java @@ -945,6 +945,8 @@ public void testUserNamesWithAndWithoutUnderscores() { assertTrue("a".matches(GitHubSCMSource.VALID_GITHUB_USER_NAME)); assertTrue("0".matches(GitHubSCMSource.VALID_GITHUB_USER_NAME)); assertTrue("a-b-c-d-e-f-g".matches(GitHubSCMSource.VALID_GITHUB_USER_NAME)); + assertTrue("a.b".matches(GitHubSCMSource.VALID_GITHUB_USER_NAME)); + assertTrue("a.b.c".matches(GitHubSCMSource.VALID_GITHUB_USER_NAME)); // Valid names should contain alphanumeric characters or single hyphens, and cannot begin or end // with a hyphen, and have a 39 char limit @@ -960,5 +962,8 @@ public void testUserNamesWithAndWithoutUnderscores() { assertFalse("user123-_org456".matches(GitHubSCMSource.VALID_GITHUB_USER_NAME)); assertFalse("user123_org456-code789".matches(GitHubSCMSource.VALID_GITHUB_USER_NAME)); assertFalse("user123_org456_code789".matches(GitHubSCMSource.VALID_GITHUB_USER_NAME)); + assertFalse(".user123_org456_code789".matches(GitHubSCMSource.VALID_GITHUB_USER_NAME)); + assertFalse("user123_org456_code789.".matches(GitHubSCMSource.VALID_GITHUB_USER_NAME)); + assertFalse("a..b".matches(GitHubSCMSource.VALID_GITHUB_USER_NAME)); } }