diff --git a/webui/build.gradle b/webui/build.gradle index 90743ccd..fa2b00e0 100644 --- a/webui/build.gradle +++ b/webui/build.gradle @@ -47,6 +47,8 @@ task precompileJsp { ant.javac(srcDir: 'build/tmp_jsp', classPath : sourceSets.main.runtimeClasspath.asPath, debug : true, + includeAntRuntime : false, + deprecation : "on", destDir:file("$buildDir/compiledJsps")) } diff --git a/webui/src/main/java/com/muwire/webui/DownloadServlet.java b/webui/src/main/java/com/muwire/webui/DownloadServlet.java index d3b1e877..9bd660d1 100644 --- a/webui/src/main/java/com/muwire/webui/DownloadServlet.java +++ b/webui/src/main/java/com/muwire/webui/DownloadServlet.java @@ -87,10 +87,19 @@ public class DownloadServlet extends HttpServlet { protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String infoHashB64 = req.getParameter("infoHash"); - InfoHash infoHash = new InfoHash(Base64.decode(infoHashB64)); + if (infoHashB64 == null) { + resp.sendError(403, "Bad param"); + return; + } + byte[] h = Base64.decode(infoHashB64); + if (h == null || h.length != InfoHash.SIZE) { + resp.sendError(403, "Bad param"); + return; + } + InfoHash infoHash = new InfoHash(h); String action = req.getParameter("action"); if (action == null) { - resp.sendError(403, "Bad action param"); + resp.sendError(403, "Bad param"); return; } if (action.equals("start")) { @@ -118,5 +127,7 @@ public class DownloadServlet extends HttpServlet { } downloadManager.cancel(infoHash); } + // P-R-G + resp.sendRedirect("/MuWire/Downloads.jsp"); } } diff --git a/webui/src/main/js/conncount.js b/webui/src/main/js/conncount.js index e5dd861a..463d2870 100644 --- a/webui/src/main/js/conncount.js +++ b/webui/src/main/js/conncount.js @@ -1,14 +1,16 @@ function refreshConnectionsCount() { var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function() { - if (this.readyState == 4 && this.status == 200) { + if (this.readyState == 4) { + var connectionCountSpan = document.getElementById("connectionsCount"); + if (this.status == 200) { var connections = this.responseXML.getElementsByTagName("Connections"); var count = connections[0].childNodes[0].nodeValue - var connectionCountSpan = document.getElementById("connectionsCount"); var countString = ""+count; connectionCountSpan.innerHTML = countString; - } else { + } else { connectionCountSpan.innerHTML = "down"; + } } } xmlhttp.open("GET", "/MuWire/Search?section=connectionsCount", true); diff --git a/webui/src/main/webapp/Downloads.jsp b/webui/src/main/webapp/Downloads.jsp index 8557ce97..9019cc8d 100644 --- a/webui/src/main/webapp/Downloads.jsp +++ b/webui/src/main/webapp/Downloads.jsp @@ -20,6 +20,7 @@
<%@include file="header.jsi"%>