mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-06-06 18:30:57 +00:00
Update Regex to remove unwanted character matching
This commit is contained in:
parent
87ade7e60b
commit
1c9f618882
@ -124,14 +124,14 @@ public class AppConfig {
|
||||
|
||||
if (!uploadLimit || maxUploadSize == null || maxUploadSize.isEmpty()) {
|
||||
return 0;
|
||||
} else if (!new Regex("^[1-9][0-9]{0,2}[K|M|G]B$").matches(maxUploadSize)) {
|
||||
} else if (!new Regex("^[1-9][0-9]{0,2}[KMGkmg][Bb]$").matches(maxUploadSize)) {
|
||||
log.error(
|
||||
"Invalid maxUploadSize format. Expected format: [1-9][0-9]{0,2}[K|M|G]B, but got: {}",
|
||||
"Invalid maxUploadSize format. Expected format: [1-9][0-9]{0,2}[KMGkmg][Bb], but got: {}",
|
||||
maxUploadSize);
|
||||
return 0;
|
||||
} else {
|
||||
String unit = maxUploadSize.replaceAll("[1-9][0-9]{0,2}", "");
|
||||
String number = maxUploadSize.replaceAll("[K|M|G]B", "");
|
||||
String unit = maxUploadSize.replaceAll("[1-9][0-9]{0,2}", "").toUpperCase();
|
||||
String number = maxUploadSize.replaceAll("[KMGkmg][Bb]", "");
|
||||
long size = Long.parseLong(number);
|
||||
return switch (unit) {
|
||||
case "KB" -> size * 1024;
|
||||
|
Loading…
x
Reference in New Issue
Block a user