Commit b1c22b3e authored by Matt Tucker's avatar Matt Tucker Committed by matt

Fixed serving of images.


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@466 b35dd754-fafc-0310-a699-88a17e54d16e
parent 9dc228c2
...@@ -27,6 +27,7 @@ import java.io.*; ...@@ -27,6 +27,7 @@ import java.io.*;
import java.util.Map; import java.util.Map;
import java.util.List; import java.util.List;
import java.util.HashMap; import java.util.HashMap;
import java.util.Arrays;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
/** /**
...@@ -71,10 +72,12 @@ public class PluginServlet extends HttpServlet { ...@@ -71,10 +72,12 @@ public class PluginServlet extends HttpServlet {
// Handle JSP requests. // Handle JSP requests.
if (pathInfo.endsWith(".jsp")) { if (pathInfo.endsWith(".jsp")) {
handleJSP(pathInfo, request, response); handleJSP(pathInfo, request, response);
return;
} }
// Handle image requests. // Handle image requests.
else if (pathInfo.endsWith(".gif") || pathInfo.endsWith(".png")) { else if (pathInfo.endsWith(".gif") || pathInfo.endsWith(".png")) {
handleImage(pathInfo, response); handleImage(pathInfo, response);
return;
} }
// Anything else results in a 404. // Anything else results in a 404.
else { else {
...@@ -166,7 +169,14 @@ public class PluginServlet extends HttpServlet { ...@@ -166,7 +169,14 @@ public class PluginServlet extends HttpServlet {
*/ */
private void handleImage(String pathInfo, HttpServletResponse response) throws IOException private void handleImage(String pathInfo, HttpServletResponse response) throws IOException
{ {
File image = new File(pluginDirectory, pathInfo.replaceAll("/", File.separator)); String [] parts = pathInfo.split("/");
// Image request must be in correct format.
if (parts.length != 4) {
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
return;
}
File image = new File(pluginDirectory, parts[1] + File.separator + "web" +
File.separator + "images" + File.separator + parts[3]);
if (!image.exists()) { if (!image.exists()) {
response.setStatus(HttpServletResponse.SC_NOT_FOUND); response.setStatus(HttpServletResponse.SC_NOT_FOUND);
return; return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment