mirror of
https://github.com/plexusorg/Module-HTTPD.git
synced 2024-11-21 11:15:01 +00:00
uhhhh
uhhhhhh 😳
This commit is contained in:
parent
2117cf7041
commit
f8bd688fa5
@ -15,7 +15,6 @@ import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.text.CharacterIterator;
|
||||
import java.text.StringCharacterIterator;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import lombok.Data;
|
||||
|
@ -28,7 +28,7 @@ public class SchematicUploadServlet extends HttpServlet
|
||||
return;
|
||||
}
|
||||
File[] schematics = worldeditFolder.listFiles();
|
||||
Part uploadPart = null;
|
||||
Part uploadPart;
|
||||
try
|
||||
{
|
||||
uploadPart = req.getPart("file");
|
||||
@ -39,19 +39,21 @@ public class SchematicUploadServlet extends HttpServlet
|
||||
return;
|
||||
}
|
||||
String filename = uploadPart.getSubmittedFileName().replaceAll("[^a-zA-Z0-9'!,_ .-]", "_");
|
||||
if (schemNameMatcher.matcher(filename).matches())
|
||||
if (!schemNameMatcher.matcher(filename).matches())
|
||||
{
|
||||
boolean alreadyExists = schematics != null && Arrays.stream(schematics).anyMatch(file -> HTTPDModule.fileNameEquals(file.getName(), filename));
|
||||
if (alreadyExists)
|
||||
{
|
||||
resp.getWriter().println(schematicUploadBadHTML("A schematic with the name <b>" + filename + "</b> already exists!"));
|
||||
return;
|
||||
}
|
||||
InputStream inputStream = uploadPart.getInputStream();
|
||||
Files.copy(inputStream, new File(worldeditFolder, filename).toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||
inputStream.close();
|
||||
resp.getWriter().println(schematicUploadGoodHTML("Successfully uploaded <b>" + filename + "."));
|
||||
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));
|
||||
if (alreadyExists)
|
||||
{
|
||||
resp.getWriter().println(schematicUploadBadHTML("A schematic with the name <b>" + filename + "</b> already exists!"));
|
||||
return;
|
||||
}
|
||||
InputStream inputStream = uploadPart.getInputStream();
|
||||
Files.copy(inputStream, new File(worldeditFolder, filename).toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||
inputStream.close();
|
||||
resp.getWriter().println(schematicUploadGoodHTML("Successfully uploaded <b>" + filename + "."));
|
||||
}
|
||||
|
||||
private String schematicUploadBadHTML(String message)
|
||||
|
Loading…
Reference in New Issue
Block a user