File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed
main/java/org/commonjava/atlas/maven/ident/util
test/java/org/commonjava/atlas/maven/ident/util Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,15 @@ public static ArtifactPathInfo parse( final String path )
8080 .replace ( '/' , '.' );
8181 final String a = matcher .group ( ARTIFACT_ID_GROUP );
8282 final String v = matcher .group ( VERSION_GROUP );
83+ final String f = matcher .group ( FILE_GROUP );
84+
85+ // Validate that the filename follows standard Maven layout: {artifactId}-{version}-...
86+ // This prevents mis-parsing paths that match the regex pattern but don't follow Maven conventions
87+ String expectedPrefix = a + "-" + v ;
88+ if ( !f .startsWith ( expectedPrefix ) || f .contains ( "/" ) )
89+ {
90+ return null ;
91+ }
8392
8493 String c = "" ;
8594 String t = null ;
@@ -131,8 +140,6 @@ public static ArtifactPathInfo parse( final String path )
131140 c = left .substring ( 0 , leftLen - extLen );
132141 }
133142
134- final String f = matcher .group ( FILE_GROUP );
135-
136143 if ( checksumType != null && CHECKSUM_TYPES .contains ( checksumType ) )
137144 {
138145 t = t + checksumType ;
Original file line number Diff line number Diff line change @@ -191,6 +191,15 @@ public void matchCompoundExtTypes2(){
191191 assertThat ( info .getType (), equalTo ( "a.b.c" ) );
192192 }
193193
194+ @ Test
195+ public void testNonStandardRpmPathReturnsNull ()
196+ {
197+ // RPM path where filename doesn't follow Maven naming convention
198+ String path = "/org/jboss/pnc/rpm/org/hibernate/search/hibernate-search-integrationtest-jakarta-jb-eap-8.0-rhel-9/6.2.2.Final/eap8-hibernate-search-6.2.2-1.Final.1.el8.src.rpm" ;
199+ ArtifactPathInfo info = ArtifactPathInfo .parse ( path );
200+ assertThat ( info , equalTo ( null ) );
201+ }
202+
194203 @ Test
195204 public void testChecksumTypes ()
196205 {
You can’t perform that action at this time.
0 commit comments