In the below code base, I am providing Pattern.LITERAL as one of the flags to Pattern.compile(String regex, int flags) method and wanted advise whether this flag can mitigate regular expression injection(https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS) in Java or not? Below is an example pattern i have provided as an example. The string this regex is checked against is an user provided input.
private final int flags = Pattern.CASE_INSENSITIVE | Pattern.LITERAL;
Pattern patternCheck = Pattern.compile("check\\s+test\\s+([\\w\\s-]+)cd(\\s+" + variable1 +
"|\\s+abc\\s+" + variable2 + ")\\s+to\\s+(abc|xyz)\\s+test\\s+ab\\s+xyz",flags);