Return HTTP status 400 instead of 500, when the path cannot be properly decoded.
authorpastith <devnull@localhost>
Thu, 2 Apr 2009 09:38:35 +0000 (09:38 +0000)
committerpastith <devnull@localhost>
Thu, 2 Apr 2009 09:38:35 +0000 (09:38 +0000)
gss/src/gr/ebs/gss/server/rest/FilesHandler.java

index 0412c53..825b9e2 100644 (file)
@@ -576,7 +576,12 @@ public class FilesHandler extends RequestHandler {
        }
         String path = getInnerPath(req, PATH_FILES);
        path = path.endsWith("/")? path: path + '/';
-       path = URLDecoder.decode(path, "UTF-8");
+               try {
+               path = URLDecoder.decode(path, "UTF-8");
+               } catch (IllegalArgumentException e) {
+                       resp.sendError(HttpServletResponse.SC_BAD_REQUEST, e.getMessage());
+                       return;
+               }
        // We only defer authenticating multipart POST requests.
        if (authDeferred) {
                        if (!ServletFileUpload.isMultipartContent(req)) {