Fixed: partymgr fails to upload image
This is a bug due to fileToCheck is the complete name of the file
with path not the filename
Thanks: Wai for report
@@ -105,11 +105,13 @@ public class SecuredUpload {
return true;
}
+ Path p = Paths.get(fileToCheck);
+ String file = p.getFileName().toString();
if (org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS) {
if (fileToCheck.length() > 259) {
Debug.logError("Uploaded file name too long", MODULE);
return false;
- } else if (!fileToCheck.matches("[a-zA-Z0-9]{1,249}.[a-zA-Z0-9]{1,10}")) {
+ } else if (!file.matches("[a-zA-Z0-9]{1,249}.[a-zA-Z0-9]{1,10}")) {
Debug.logError("Uploaded file "
+ " should contain only Alpha-Numeric characters, only 1 dot as an input for the file name and the extension."
+ "The file name and the extension should not be empty at all",
@@ -120,7 +122,7 @@ public class SecuredUpload {
if (fileToCheck.length() > 4096) {
Debug.logError("Uploaded file name too long", MODULE);
return false;
- } else if (!fileToCheck.matches("[a-zA-Z0-9]{1,4086}.[a-zA-Z0-9]{1,10}")) {
+ } else if (!file.matches("[a-zA-Z0-9]{1,4086}.[a-zA-Z0-9]{1,10}")) {
Debug.logError("Uploaded file "
+ " should contain only Alpha-Numeric characters, only 1 dot as an input for the file name and the extension."
+ "Tthe file name and the extension should not be empty at all",
