mirror of https://github.com/apache/archiva.git
Adding some tests for invalid request paths.
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@587701 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ac7babe5a1
commit
89079a2684
|
@ -99,13 +99,30 @@ public class RepositoryRequest
|
||||||
public ArtifactReference toArtifactReference( String requestedPath )
|
public ArtifactReference toArtifactReference( String requestedPath )
|
||||||
throws LayoutException
|
throws LayoutException
|
||||||
{
|
{
|
||||||
if ( isDefault( requestedPath ) )
|
if ( StringUtils.isBlank( requestedPath ) )
|
||||||
{
|
{
|
||||||
return DefaultPathParser.toArtifactReference( requestedPath );
|
throw new LayoutException( "Blank request path is not a valid." );
|
||||||
}
|
}
|
||||||
else if ( isLegacy( requestedPath ) )
|
|
||||||
|
String path = requestedPath;
|
||||||
|
while ( path.startsWith( "/" ) )
|
||||||
{
|
{
|
||||||
return LegacyPathParser.toArtifactReference( requestedPath );
|
path = path.substring( 1 );
|
||||||
|
|
||||||
|
// Only slash? that's bad, mmm-kay?
|
||||||
|
if ( "/".equals( path ) )
|
||||||
|
{
|
||||||
|
throw new LayoutException( "Invalid request path: Slash only." );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( isDefault( path ) )
|
||||||
|
{
|
||||||
|
return DefaultPathParser.toArtifactReference( path );
|
||||||
|
}
|
||||||
|
else if ( isLegacy( path ) )
|
||||||
|
{
|
||||||
|
return LegacyPathParser.toArtifactReference( path );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -127,6 +127,8 @@ public class RepositoryRequestTest
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
assertValid( "org.apache.derby/poms/derby-10.2.2.0.pom", "org.apache.derby", "derby", "10.2.2.0", null, "pom" );
|
assertValid( "org.apache.derby/poms/derby-10.2.2.0.pom", "org.apache.derby", "derby", "10.2.2.0", null, "pom" );
|
||||||
|
// Starting slash should not prevent detection.
|
||||||
|
assertValid( "/org.apache.derby/poms/derby-10.2.2.0.pom", "org.apache.derby", "derby", "10.2.2.0", null, "pom" );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testValidDefaultDerbyPom()
|
public void testValidDefaultDerbyPom()
|
||||||
|
|
Loading…
Reference in New Issue