Repository: Stirling-Tools/Stirling-PDF
File: src/main/java/stirling/software/SPDF/config/AppConfig.java (Java)

Code before:
                ? applicationProperties.getSystem().getEnableAlphaFunctionality()
                : false;
    }

    @Bean(name = "rateLimit")
    public boolean rateLimit() {
        String rateLimit = System.getProperty("rateLimit");
        if (rateLimit == null) rateLimit = System.getenv("rateLimit");
        return (rateLimit != null) ? Boolean.valueOf(rateLimit) : false;
    }

    @Bean(name = "uploadLimit")
    public long uploadLimit() {
        boolean uploadLimit =
                applicationProperties.getSystem().getUploadLimit().getEnableUploadSizeLimit()
                                != null
                        ? applicationProperties
                                .getSystem()
                                .getUploadLimit()
                                .getEnableUploadSizeLimit()
                        : false;
        if (!uploadLimit) {
            return 0;
        }
        String maxUploadSize = applicationProperties.getSystem().getUploadLimit().getLimit();
        if (!new Regex("^[1-9][0-9]{0,2}[K|M|G]B$").matches(maxUploadSize)) {
            log.error(
                    "Invalid maxUploadSize format. Expected format: {1,3}[0-9][K|M|G]B, but got: {}",
                    maxUploadSize);
            return 0;
        }
        if (maxUploadSize == null || maxUploadSize.isEmpty()) {
            return 0;
        } else {
            String unit = maxUploadSize.replaceAll("[1-9][0-9]{0,2}", "");
            String number = maxUploadSize.replaceAll("[K|M|G]B", "");
            long size = Long.parseLong(number);
            return switch (unit) {
                case "KB" -> size * 1024;
                case "MB" -> size * 1024 * 1024;
                case "GB" -> size * 1024 * 1024 * 1024;
                default -> 0;
            };
        }
    }

    @Bean(name = "RunningInDocker")
    public boolean runningInDocker() {
        return Files.exists(Paths.get("/.dockerenv"));
    }


Review comment (suggestion):
Your regex captures the '|' character too. 
![{535B419E-A55C-4DC0-9620-69FDF87BD751}](https://github.com/user-attachments/assets/b2119652-f666-47c7-9c28-432d6284f0b8)
![{3F13AF61-6387-4287-89EC-224774489A0B}](https://github.com/user-attachments/assets/5f3d486b-1a75-4486-a50d-50d8eadd9edc)

Use: `^[1-9][0-9]{0,2}[KMG]B$` instead.


Code after:
                ? applicationProperties.getSystem().getEnableAlphaFunctionality()
                : false;
    }

    @Bean(name = "rateLimit")
    public boolean rateLimit() {
        String rateLimit = System.getProperty("rateLimit");
        if (rateLimit == null) rateLimit = System.getenv("rateLimit");
        return (rateLimit != null) ? Boolean.valueOf(rateLimit) : false;
    }

    @Bean(name = "uploadLimit")
    public long uploadLimit() {
        String maxUploadSize =
                applicationProperties.getSystem().getFileUploadLimit() != null
                        ? applicationProperties.getSystem().getFileUploadLimit()
                        : "";

        if (maxUploadSize.isEmpty()) {
            return 0;
        } 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}[KMGkmg][Bb], but got: {}",
                    maxUploadSize);
            return 0;
        } else {
            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;
                case "MB" -> size * 1024 * 1024;
                case "GB" -> size * 1024 * 1024 * 1024;
                default -> 0;
            };
        }
    }

    @Bean(name = "RunningInDocker")
    public boolean runningInDocker() {
        return Files.exists(Paths.get("/.dockerenv"));
    }

    @Bean(name = "configDirMounted")
    public boolean isRunningInDockerWithConfig() {
        Path dockerEnv = Paths.get("/.dockerenv");
        // default to true if not docker
        if (!Files.exists(dockerEnv)) {
            return true;
        }
        Path mountInfo = Paths.get("/proc/1/mountinfo");