@Test public void path_does_not_contain_a_period() throws Exception { Request request = newRequest("/start"); Response response = mockResponse(); RequestHandler handler = mockRequestHandler(); Context context = mockContext(); train_service(handler, request, response, true); replay(); RequestFilter filter = new StaticFilesFilter(context); assertTrue(filter.service(request, response, handler)); verify(); }
public boolean service(Request request, Response response, RequestHandler handler) throws IOException { String path = request.getPath(); if (path.equals("/favicon.ico")) return false; if (!path.contains(":")) { int dotx = path.lastIndexOf("."); if (dotx > 0) { URL url = context.getResource(path); if (url != null) { String suffix = path.substring(dotx + 1); if (suffix.equalsIgnoreCase(TapestryConstants.TEMPLATE_EXTENSION)) { response.sendError(HttpServletResponse.SC_FORBIDDEN, String.format("URI %s may not be accessed remotely.", path)); return true; } return false; } } } return handler.service(request, response); }
StaticFilesFilter implements RequestFilter { public boolean service(Request request, Response response, RequestHandler handler) throws IOException { String path = request.getPath(); if (path.equals("/favicon.ico")) return false; if (!path.contains(":")) { int dotx = path.lastIndexOf("."); if (dotx > 0) { URL url = context.getResource(path); if (url != null) { String suffix = path.substring(dotx + 1); if (suffix.equalsIgnoreCase(TapestryConstants.TEMPLATE_EXTENSION)) { response.sendError(HttpServletResponse.SC_FORBIDDEN, String.format("URI %s may not be accessed remotely.", path)); return true; } return false; } } } return handler.service(request, response); } }
StaticFilesFilter implements RequestFilter { public boolean service(Request request, Response response, RequestHandler handler) throws IOException { String path = request.getPath(); if (path.equals("/favicon.ico")) return false; if (!path.contains(":")) { int dotx = path.lastIndexOf("."); if (dotx > 0) { URL url = context.getResource(path); if (url != null) { String suffix = path.substring(dotx + 1); if (suffix.equalsIgnoreCase(TapestryConstants.TEMPLATE_EXTENSION)) { response.sendError(HttpServletResponse.SC_FORBIDDEN, String.format("URI %s may not be accessed remotely.", path)); return true; } return false; } } } return handler.service(request, response); } StaticFilesFilter(Context context); }
StaticFilesFilter implements RequestFilter { public boolean service(Request request, Response response, RequestHandler handler) throws IOException { String path = request.getPath(); if (path.equals("/favicon.ico")) return false; if (!path.contains(":")) { int dotx = path.lastIndexOf("."); if (dotx > 0) { URL url = context.getResource(path); if (url != null) { String suffix = path.substring(dotx + 1); if (suffix.equalsIgnoreCase(TapestryConstants.TEMPLATE_EXTENSION)) { response.sendError(HttpServletResponse.SC_FORBIDDEN, String.format("URI %s may not be accessed remotely.", path)); return true; } return false; } } } return handler.service(request, response); } StaticFilesFilter(Context context); boolean service(Request request, Response response, RequestHandler handler); }
StaticFilesFilter implements RequestFilter { public boolean service(Request request, Response response, RequestHandler handler) throws IOException { String path = request.getPath(); if (path.equals("/favicon.ico")) return false; if (!path.contains(":")) { int dotx = path.lastIndexOf("."); if (dotx > 0) { URL url = context.getResource(path); if (url != null) { String suffix = path.substring(dotx + 1); if (suffix.equalsIgnoreCase(TapestryConstants.TEMPLATE_EXTENSION)) { response.sendError(HttpServletResponse.SC_FORBIDDEN, String.format("URI %s may not be accessed remotely.", path)); return true; } return false; } } } return handler.service(request, response); } StaticFilesFilter(Context context); boolean service(Request request, Response response, RequestHandler handler);  }