mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-18 15:33:09 +00:00
(Robert Tansley)
- Error pages now return appropriate HTTP status codes (e.g. 404 not found) - Bad filenames in /bitstream/ URLs now result in 404 error -- prevents infinite URL spaces confusing crawlers and bad "persistent" bitstream IDs circulating git-svn-id: http://scm.dspace.org/svn/repo/trunk@1671 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
@@ -1,3 +1,9 @@
|
|||||||
|
(Robert Tansley)
|
||||||
|
- Error pages now return appropriate HTTP status codes (e.g. 404 not found)
|
||||||
|
- Bad filenames in /bitstream/ URLs now result in 404 error -- prevents
|
||||||
|
infinite URL spaces confusing crawlers and bad "persistent" bitstream IDs
|
||||||
|
circulating
|
||||||
|
|
||||||
1.4.1 beta 1
|
1.4.1 beta 1
|
||||||
============
|
============
|
||||||
(Scott Yeadon)
|
(Scott Yeadon)
|
||||||
|
@@ -92,6 +92,7 @@ public class BitstreamServlet extends DSpaceServlet
|
|||||||
String idString = request.getPathInfo();
|
String idString = request.getPathInfo();
|
||||||
String handle = "";
|
String handle = "";
|
||||||
String sequenceText = "";
|
String sequenceText = "";
|
||||||
|
String filename = null;
|
||||||
int sequenceID;
|
int sequenceID;
|
||||||
|
|
||||||
// Parse 'handle' and 'sequence' (bitstream seq. number) out
|
// Parse 'handle' and 'sequence' (bitstream seq. number) out
|
||||||
@@ -117,9 +118,10 @@ public class BitstreamServlet extends DSpaceServlet
|
|||||||
handle = idString.substring(0, slashIndex);
|
handle = idString.substring(0, slashIndex);
|
||||||
int slash2 = idString.indexOf('/', slashIndex + 1);
|
int slash2 = idString.indexOf('/', slashIndex + 1);
|
||||||
if (slash2 != -1)
|
if (slash2 != -1)
|
||||||
|
{
|
||||||
sequenceText = idString.substring(slashIndex+1,slash2);
|
sequenceText = idString.substring(slashIndex+1,slash2);
|
||||||
else
|
filename = idString.substring(slash2+1);
|
||||||
sequenceText = idString.substring(slashIndex+1);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,10 +169,10 @@ public class BitstreamServlet extends DSpaceServlet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bitstream == null)
|
if (bitstream == null || filename == null
|
||||||
|
|| !filename.equals(bitstream.getName()))
|
||||||
{
|
{
|
||||||
// No bitstream found -- ID was invalid
|
// No bitstream found or filename was wrong -- ID invalid
|
||||||
|
|
||||||
log.info(LogManager.getHeader(context, "invalid_id", "path="
|
log.info(LogManager.getHeader(context, "invalid_id", "path="
|
||||||
+ idString));
|
+ idString));
|
||||||
JSPManager.showInvalidIDError(request, response, idString,
|
JSPManager.showInvalidIDError(request, response, idString,
|
||||||
|
@@ -102,6 +102,7 @@ public class JSPManager
|
|||||||
public static void showInternalError(HttpServletRequest request,
|
public static void showInternalError(HttpServletRequest request,
|
||||||
HttpServletResponse response) throws ServletException, IOException
|
HttpServletResponse response) throws ServletException, IOException
|
||||||
{
|
{
|
||||||
|
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
|
||||||
showJSP(request, response, "/error/internal.jsp");
|
showJSP(request, response, "/error/internal.jsp");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,6 +118,7 @@ public class JSPManager
|
|||||||
public static void showIntegrityError(HttpServletRequest request,
|
public static void showIntegrityError(HttpServletRequest request,
|
||||||
HttpServletResponse response) throws ServletException, IOException
|
HttpServletResponse response) throws ServletException, IOException
|
||||||
{
|
{
|
||||||
|
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
|
||||||
showJSP(request, response, "/error/integrity.jsp");
|
showJSP(request, response, "/error/integrity.jsp");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,6 +139,7 @@ public class JSPManager
|
|||||||
throws ServletException, IOException
|
throws ServletException, IOException
|
||||||
{
|
{
|
||||||
// FIXME: Need to work out which error message to display?
|
// FIXME: Need to work out which error message to display?
|
||||||
|
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
|
||||||
showJSP(request, response, "/error/authorize.jsp");
|
showJSP(request, response, "/error/authorize.jsp");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,6 +164,7 @@ public class JSPManager
|
|||||||
throws ServletException, IOException
|
throws ServletException, IOException
|
||||||
{
|
{
|
||||||
request.setAttribute("bad.id", badID);
|
request.setAttribute("bad.id", badID);
|
||||||
|
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
|
||||||
|
|
||||||
if (type != -1)
|
if (type != -1)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user