diff options
author | Olivier Lamy <olamy@apache.org> | 2014-10-14 15:02:22 +1100 |
---|---|---|
committer | Olivier Lamy <olamy@apache.org> | 2014-10-14 15:59:00 +1100 |
commit | 84d5a61c80a49222e62f4c65a7eb402e042e9a66 (patch) | |
tree | 794f7d068ab1e4c9dce4c745faaf4d2f53f92262 /archiva-modules/archiva-web | |
parent | 951b9f8ef15abed0fabba2ac38f1cbfd6a52d597 (diff) | |
download | archiva-84d5a61c80a49222e62f4c65a7eb402e042e9a66.tar.gz archiva-84d5a61c80a49222e62f4c65a7eb402e042e9a66.zip |
[MRM-1145] RSS tests do not correctly check responses
Diffstat (limited to 'archiva-modules/archiva-web')
2 files changed, 10 insertions, 3 deletions
diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/rss/RssFeedServlet.java b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/rss/RssFeedServlet.java index 958ad28e7..a0994cd25 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/rss/RssFeedServlet.java +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/rss/RssFeedServlet.java @@ -115,11 +115,14 @@ public class RssFeedServlet public void doGet( HttpServletRequest req, HttpServletResponse res ) throws ServletException, IOException { + + String repoId = null; String groupId = null; String artifactId = null; String url = StringUtils.removeEnd( req.getRequestURL().toString(), "/" ); + if ( StringUtils.countMatches( StringUtils.substringAfter( url, "feeds/" ), "/" ) > 0 ) { artifactId = StringUtils.substringAfterLast( url, "/" ); @@ -128,6 +131,12 @@ public class RssFeedServlet } else if ( StringUtils.countMatches( StringUtils.substringAfter( url, "feeds/" ), "/" ) == 0 ) { + // we receive feeds?babla=ded which is not correct + if ( StringUtils.countMatches( url, "feeds?" ) > 0 ) + { + res.sendError( HttpServletResponse.SC_BAD_REQUEST, "Invalid request url." ); + return; + } repoId = StringUtils.substringAfterLast( url, "/" ); } else diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/web/rss/RssFeedServletTest.java b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/web/rss/RssFeedServletTest.java index 54dab14ae..582a53225 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/web/rss/RssFeedServletTest.java +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/web/rss/RssFeedServletTest.java @@ -430,12 +430,10 @@ public class RssFeedServletTest mockHttpServletResponse.getStatus() ); } - @Ignore + @Test public void testInvalidRequest() throws Exception { - //RssFeedServlet servlet = - // (RssFeedServlet) client.newInvocation( "http://localhost/feeds?invalid_param=xxx" ).getServlet(); MockHttpServletRequest request = new MockHttpServletRequest(); request.setRequestURI( "/feeds?invalid_param=xxx" ); request.addHeader( "User-Agent", "Apache Archiva unit test" ); |