uhhhhhh 😳
This commit is contained in:
ayunami2000 2022-04-17 23:09:53 -04:00
parent 2117cf7041
commit f8bd688fa5
2 changed files with 14 additions and 13 deletions

View File

@ -15,7 +15,6 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.text.CharacterIterator; import java.text.CharacterIterator;
import java.text.StringCharacterIterator; import java.text.StringCharacterIterator;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import lombok.Data; import lombok.Data;

View File

@ -28,7 +28,7 @@ public class SchematicUploadServlet extends HttpServlet
return; return;
} }
File[] schematics = worldeditFolder.listFiles(); File[] schematics = worldeditFolder.listFiles();
Part uploadPart = null; Part uploadPart;
try try
{ {
uploadPart = req.getPart("file"); uploadPart = req.getPart("file");
@ -39,8 +39,11 @@ public class SchematicUploadServlet extends HttpServlet
return; return;
} }
String filename = uploadPart.getSubmittedFileName().replaceAll("[^a-zA-Z0-9'!,_ .-]", "_"); String filename = uploadPart.getSubmittedFileName().replaceAll("[^a-zA-Z0-9'!,_ .-]", "_");
if (schemNameMatcher.matcher(filename).matches()) if (!schemNameMatcher.matcher(filename).matches())
{ {
resp.getWriter().println(schematicUploadBadHTML("That is not a valid schematic filename!"));
return;
}
boolean alreadyExists = schematics != null && Arrays.stream(schematics).anyMatch(file -> HTTPDModule.fileNameEquals(file.getName(), filename)); boolean alreadyExists = schematics != null && Arrays.stream(schematics).anyMatch(file -> HTTPDModule.fileNameEquals(file.getName(), filename));
if (alreadyExists) if (alreadyExists)
{ {
@ -52,7 +55,6 @@ public class SchematicUploadServlet extends HttpServlet
inputStream.close(); inputStream.close();
resp.getWriter().println(schematicUploadGoodHTML("Successfully uploaded <b>" + filename + ".")); resp.getWriter().println(schematicUploadGoodHTML("Successfully uploaded <b>" + filename + "."));
} }
}
private String schematicUploadBadHTML(String message) private String schematicUploadBadHTML(String message)
{ {