aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/RepositoryRequest.java25
-rw-r--r--archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/content/RepositoryRequestTest.java4
2 files changed, 24 insertions, 5 deletions
diff --git a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/RepositoryRequest.java b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/RepositoryRequest.java
index 12158586b..7a67cf75f 100644
--- a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/RepositoryRequest.java
+++ b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/RepositoryRequest.java
@@ -99,13 +99,30 @@ public class RepositoryRequest
public ArtifactReference toArtifactReference( String requestedPath )
throws LayoutException
{
- if ( isDefault( requestedPath ) )
+ if ( StringUtils.isBlank( requestedPath ) )
+ {
+ throw new LayoutException( "Blank request path is not a valid." );
+ }
+
+ String path = requestedPath;
+ while ( path.startsWith( "/" ) )
+ {
+ 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( requestedPath );
+ return DefaultPathParser.toArtifactReference( path );
}
- else if ( isLegacy( requestedPath ) )
+ else if ( isLegacy( path ) )
{
- return LegacyPathParser.toArtifactReference( requestedPath );
+ return LegacyPathParser.toArtifactReference( path );
}
else
{
diff --git a/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/content/RepositoryRequestTest.java b/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/content/RepositoryRequestTest.java
index 0d4cfa791..2a3de5a51 100644
--- a/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/content/RepositoryRequestTest.java
+++ b/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/content/RepositoryRequestTest.java
@@ -127,8 +127,10 @@ public class RepositoryRequestTest
throws Exception
{
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()
throws Exception
{