mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-30 10:05:59 +00:00
Adjust filename filter for schematic manager.
This commit is contained in:
parent
e780c4ffec
commit
c74763c96a
@ -22,13 +22,13 @@ public class Module_schematic extends TFM_HTTPD_Module
|
|||||||
{
|
{
|
||||||
private static final File SCHEMATIC_FOLDER = new File("./plugins/WorldEdit/schematics/");
|
private static final File SCHEMATIC_FOLDER = new File("./plugins/WorldEdit/schematics/");
|
||||||
private static final String REQUEST_FORM_FILE_ELEMENT_NAME = "schematicFile";
|
private static final String REQUEST_FORM_FILE_ELEMENT_NAME = "schematicFile";
|
||||||
private static final Pattern SCHEMATIC_FILENAME_LC = Pattern.compile("^[a-z0-9]{1,30}\\.schematic$");
|
private static final Pattern SCHEMATIC_FILENAME_LC = Pattern.compile("^[a-z0-9_'!,\\-]{1,30}\\.schematic$");
|
||||||
private static final String[] SCHEMATIC_FILTER = new String[]
|
private static final String[] SCHEMATIC_FILTER = new String[]
|
||||||
{
|
{
|
||||||
"schematic"
|
"schematic"
|
||||||
};
|
};
|
||||||
private static final String UPLOAD_FORM =
|
private static final String UPLOAD_FORM
|
||||||
"<form method=\"post\" name=\"schematicForm\" id=\"schematicForm\" action=\"/schematic/upload/\" enctype=\"multipart/form-data\">\n"
|
= "<form method=\"post\" name=\"schematicForm\" id=\"schematicForm\" action=\"/schematic/upload/\" enctype=\"multipart/form-data\">\n"
|
||||||
+ "<p>Select a schematic file to upload. Filenames must be alphanumeric, between 1 and 30 characters long (inclusive), and have a .schematic extension.</p>\n"
|
+ "<p>Select a schematic file to upload. Filenames must be alphanumeric, between 1 and 30 characters long (inclusive), and have a .schematic extension.</p>\n"
|
||||||
+ "<input type=\"file\" id=\"schematicFile\" name=\"schematicFile\" />\n"
|
+ "<input type=\"file\" id=\"schematicFile\" name=\"schematicFile\" />\n"
|
||||||
+ "<br />\n"
|
+ "<br />\n"
|
||||||
@ -80,7 +80,15 @@ public class Module_schematic extends TFM_HTTPD_Module
|
|||||||
for (File schematic : schematics)
|
for (File schematic : schematics)
|
||||||
{
|
{
|
||||||
String filename = StringEscapeUtils.escapeHtml4(schematic.getName());
|
String filename = StringEscapeUtils.escapeHtml4(schematic.getName());
|
||||||
schematicsFormatted.add("<li><a href=\"/schematic/download?schematicName=" + filename + "\">" + filename + "</a></li>");
|
|
||||||
|
if (SCHEMATIC_FILENAME_LC.matcher(filename.trim().toLowerCase()).find())
|
||||||
|
{
|
||||||
|
schematicsFormatted.add("<li><a href=\"/schematic/download?schematicName=" + filename + "\">" + filename + "</a></li>");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
schematicsFormatted.add("<li>" + filename + " - (Illegal filename, can't download)</li>");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Collections.sort(schematicsFormatted, new Comparator<String>()
|
Collections.sort(schematicsFormatted, new Comparator<String>()
|
||||||
|
Loading…
Reference in New Issue
Block a user