Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ public static ArtifactPathInfo parse( final String path )
.replace( '/', '.' );
final String a = matcher.group( ARTIFACT_ID_GROUP );
final String v = matcher.group( VERSION_GROUP );
final String f = matcher.group( FILE_GROUP );

// Validate that the filename follows standard Maven layout: {artifactId}-{version}-...
// This prevents mis-parsing paths that match the regex pattern but don't follow Maven conventions
String expectedPrefix = a + "-" + v;
if ( !f.startsWith( expectedPrefix ) || f.contains( "/" ) )
{
return null;
}

String c = "";
String t = null;
Expand Down Expand Up @@ -131,8 +140,6 @@ public static ArtifactPathInfo parse( final String path )
c = left.substring( 0, leftLen - extLen );
}

final String f = matcher.group( FILE_GROUP );

if ( checksumType != null && CHECKSUM_TYPES.contains( checksumType ) )
{
t = t + checksumType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,15 @@ public void matchCompoundExtTypes2(){
assertThat( info.getType(), equalTo( "a.b.c" ) );
}

@Test
public void testNonStandardRpmPathReturnsNull()
{
// RPM path where filename doesn't follow Maven naming convention
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";
ArtifactPathInfo info = ArtifactPathInfo.parse( path );
assertThat( info, equalTo( null ) );
}

@Test
public void testChecksumTypes()
{
Expand Down