java potential path traversal 28file read 29

Solutions on MaxInterview for java potential path traversal 28file read 29 by the best coders in the world

showing results for - "java potential path traversal 28file read 29"
Amelia
25 Feb 2018
1import org.apache.commons.io.FilenameUtils;
2
3@GET
4@Path("/images/{image}")
5@Produces("images/*")
6public Response getImage(@javax.ws.rs.PathParam("image") String image) {
7    File file = new File("resources/images/", FilenameUtils.getName(image)); //Fix
8
9    if (!file.exists()) {
10        return Response.status(Status.NOT_FOUND).build();
11    }
12
13    return Response.ok().entity(new FileInputStream(file)).build();
14}
similar questions