This repository was archived by the owner on Nov 13, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
main/java/de/gesellix/docker/engine
test/groovy/de/gesellix/docker/engine Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,9 @@ public static DockerVersion parseDockerVersion(String version) {
1919
2020 final DockerVersion parsedVersion = new DockerVersion ();
2121 Matcher matcher = versionPattern .matcher (version );
22- matcher .matches ();
22+ if (!matcher .matches ()) {
23+ throw new IllegalArgumentException (String .format ("Version does not match the expected version pattern: '%s'" , version ));
24+ }
2325 parsedVersion .setMajor (Integer .parseInt (matcher .group (1 )));
2426 parsedVersion .setMinor (Integer .parseInt (matcher .group (2 )));
2527 final String s = matcher .group (3 );
Original file line number Diff line number Diff line change @@ -7,6 +7,20 @@ import static de.gesellix.docker.engine.DockerVersion.parseDockerVersion
77
88class DockerVersionSpec extends Specification {
99
10+ def " fails for invalid version" () {
11+ given :
12+ // this pattern appears in the wild for packages installed from
13+ // https://master.dockerproject.org/
14+ String versionString = " master-dockerproject-2022-03-26"
15+
16+ when :
17+ parseDockerVersion(versionString)
18+
19+ then :
20+ def e = thrown(IllegalArgumentException )
21+ e. message == " Version does not match the expected version pattern: '$versionString '"
22+ }
23+
1024 @Unroll
1125 def " parse version #versionString" () {
1226 expect :
You can’t perform that action at this time.
0 commit comments