Skip to content
This repository was archived by the owner on Mar 31, 2022. It is now read-only.

Commit 33125b7

Browse files
committed
#308 If a colon is available it must be followed by a five digit number to represent a proper port definition.
1 parent b4a5652 commit 33125b7

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

plugin/src/main/java/com/spotify/plugin/dockerfile/BuildMojo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public class BuildMojo extends AbstractDockerMojo {
5353
/**
5454
* Regex for a valid docker repository name. Used in validateRepository().
5555
*/
56-
private static final String VALID_REPO_REGEX = "^([a-z0-9_.-]+[:]?)+(\\/[a-z0-9_.-]+)*$";
56+
private static final String VALID_REPO_REGEX = "^([a-z0-9_.-])+(:[0-9]{1,5})?(\\/[a-z0-9_.-]+)*$";
5757

5858
/**
5959
* Directory containing the the build context. This is typically the directory that contains

plugin/src/test/java/com/spotify/plugin/dockerfile/TestRepoNameValidation.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,6 @@ public void testFailCases() {
6161
assertFalse("Starting slash didn't fail", BuildMojo.validateRepository("/atstart"));
6262
assertFalse("Ending slash didn't fail", BuildMojo.validateRepository("atend/"));
6363
assertFalse("Only port", BuildMojo.validateRepository(":443"));
64+
assertFalse("Port exceeding range", BuildMojo.validateRepository("example.com:100000/myproject"));
6465
}
6566
}

0 commit comments

Comments
 (0)