Skip to content

Commit 708d5f6

Browse files
author
Glyn Normington
committed
Merge 50968093- to master
[Completes #50968093]
2 parents 17a6162 + 20c8c29 commit 708d5f6

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/java_buildpack/version_resolver.rb

+2
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ def major_or_minor_and_tail(s)
102102
if s.nil? || s.empty?
103103
major_or_minor, tail = nil, nil
104104
else
105+
raise "Invalid version '#{s}': must not end in '.'" if s[-1] == '.'
105106
tokens = s.match(/^([^\.]+)(?:\.(.*))?/)
106107

107108
major_or_minor, tail = tokens[1..-1]
@@ -116,6 +117,7 @@ def micro_and_qualifier(s)
116117
if s.nil? || s.empty?
117118
micro, qualifier = nil, nil
118119
else
120+
raise "Invalid version '#{s}': must not end in '_'" if s[-1] == '_'
119121
tokens = s.match(/^([^\_]+)(?:_(.*))?/)
120122

121123
micro, qualifier = tokens[1..-1]

spec/java_buildpack/version_resolver_spec.rb

+6
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,10 @@
129129
expect { JavaBuildpack::VersionResolver.resolve('1.6.0_25', ['+']) }.to raise_error
130130
end
131131

132+
it 'should raise an exception when a version ends with a component separator' do
133+
expect { JavaBuildpack::VersionResolver.resolve('1.', ['1.']) }.to raise_error
134+
expect { JavaBuildpack::VersionResolver.resolve('1.7.', ['1.7.']) }.to raise_error
135+
expect { JavaBuildpack::VersionResolver.resolve('1.7.0_', ['1.7.0_']) }.to raise_error
136+
end
137+
132138
end

0 commit comments

Comments
 (0)