Tweak filename rule.

This commit is contained in:
Steven Lawson 2013-09-03 21:03:40 -04:00
parent 3c9245bfaf
commit b845ff3f7e

View File

@ -23,14 +23,14 @@ 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]{5,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 5 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"
+ "<button type=\"submit\">Submit</button>\n" + "<button type=\"submit\">Submit</button>\n"
@ -178,7 +178,7 @@ public class Module_schematic extends TFM_HTTPD_Module
if (!SCHEMATIC_FILENAME_LC.matcher(origFileName.toLowerCase()).find()) if (!SCHEMATIC_FILENAME_LC.matcher(origFileName.toLowerCase()).find())
{ {
throw new SchematicTransferException("File name must be alphanumeric with a \".schematic\" extension."); throw new SchematicTransferException("File name must be alphanumeric, between 1 and 30 characters long (inclusive), and have a \".schematic\" extension.");
} }
final File targetFile = new File(SCHEMATIC_FOLDER.getPath(), origFileName); final File targetFile = new File(SCHEMATIC_FOLDER.getPath(), origFileName);