aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaria Odea B. Ching <oching@apache.org>2008-08-12 07:50:27 +0000
committerMaria Odea B. Ching <oching@apache.org>2008-08-12 07:50:27 +0000
commitab7e59db215e3b0fb14bbd050413c6b3a0b1d573 (patch)
treed77d5203d2c0beca57c10d405e85976f8d5119a7
parent810d371810ad78d8cf7f60387b87f80866f36140 (diff)
downloadarchiva-ab7e59db215e3b0fb14bbd050413c6b3a0b1d573.tar.gz
archiva-ab7e59db215e3b0fb14bbd050413c6b3a0b1d573.zip
[MRM-893]
submitted by Dan Tran -return a 404 when the request is a resource file appended with a '/' git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@685076 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java11
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletBrowseTest.java24
2 files changed, 35 insertions, 0 deletions
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java
index 861df090f..0e8277359 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java
+++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java
@@ -409,6 +409,17 @@ public class ArchivaDavResourceFactory
throws DavException
{
File resourceFile = new File( managedRepository.getRepoRoot(), logicalResource.getPath() );
+
+ //MRM-893, dont send back a file when user intentionally wants a directory
+ if ( locator.getHref( false ).endsWith( "/" ) )
+ {
+ if ( ! resourceFile.isDirectory() )
+ {
+ //force a resource not found
+ return null;
+ }
+ }
+
ArchivaDavResource resource =
new ArchivaDavResource( resourceFile.getAbsolutePath(), logicalResource.getPath(),
managedRepository.getRepository(), request.getRemoteAddr(),
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletBrowseTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletBrowseTest.java
index baa76521b..169c90fab 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletBrowseTest.java
+++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletBrowseTest.java
@@ -72,6 +72,30 @@ public class RepositoryServletBrowseTest
String expectedLinks[] = new String[] { "../", "apache/", "codehaus/" };
assertLinks(expectedLinks, response.getLinks());
}
+
+ public void testGetDirectoryWhichHasMatchingFile() //MRM-893
+ throws Exception
+ {
+ new File( repoRootInternal, "org/apache/archiva/artifactId/1.0" ).mkdirs();
+ new File( repoRootInternal, "org/apache/archiva/artifactId/1.0/artifactId-1.0.jar" ).createNewFile();
+
+ WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/org/apache/archiva/artifactId" );
+ WebResponse response = sc.getResponse( request );
+ assertEquals( "Response", HttpServletResponse.SC_OK, response.getResponseCode() );
+
+ request = new GetMethodWebRequest( "http://machine.com/repository/internal/org/apache/archiva/artifactId/" );
+ response = sc.getResponse( request );
+ assertEquals( "Response", HttpServletResponse.SC_OK, response.getResponseCode() );
+
+ request = new GetMethodWebRequest( "http://machine.com/repository/internal/org/apache/archiva/artifactId/1.0/artifactId-1.0.jar" );
+ response = sc.getResponse( request );
+ assertEquals( "Response", HttpServletResponse.SC_OK, response.getResponseCode() );
+
+ request = new GetMethodWebRequest( "http://machine.com/repository/internal/org/apache/archiva/artifactId/1.0/artifactId-1.0.jar/" );
+ response = sc.getResponse( request );
+ assertEquals( "Response", HttpServletResponse.SC_NOT_FOUND, response.getResponseCode() );
+ }
+
private void assertLinks(String expectedLinks[], WebLink actualLinks[])
{