Skip to content

Commit dce04ac

Browse files
committed
fix: use atomic and non capturing regex groups
1 parent 78fd43d commit dce04ac

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

legacyspigot/src/main/java/com/sekwah/advancedportals/legacyspigot/tags/ConditionsTag.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public String description() {
6565
}
6666

6767
private boolean checkConditions(String condition, Player player) {
68-
Pattern operatorPattern = Pattern.compile("\\s*(<=|>=|<|>|==|!=)\\s*");
68+
Pattern operatorPattern = Pattern.compile("(?>\\s*)(<=|>=|<|>|==|!=)(?>\\s*)");
6969
Matcher matcher = operatorPattern.matcher(condition);
7070
if (!matcher.find()) {
7171
infoLogger.warning("Invalid operator: " + condition);
@@ -138,7 +138,7 @@ public boolean created(TagTarget target, PlayerContainer player, String[] argDat
138138
}
139139

140140
private boolean isValidConditionSyntax(String condition) {
141-
Pattern operatorPattern = Pattern.compile("\\s*(<=|>=|<|>|==|!=)\\s*");
141+
Pattern operatorPattern = Pattern.compile("(?>\\s*)(?:<=|>=|<|>|==|!=)(?>\\s*)");
142142
Matcher matcher = operatorPattern.matcher(condition);
143143
if (!matcher.find()) return false;
144144
int operatorStart = matcher.start();

spigot/src/main/java/com/sekwah/advancedportals/spigot/tags/ConditionsTag.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public String description() {
6565
}
6666

6767
private boolean checkConditions(String condition, Player player) {
68-
Pattern operatorPattern = Pattern.compile("\\s*(<=|>=|<|>|==|!=)\\s*");
68+
Pattern operatorPattern = Pattern.compile("(?>\\s*)(<=|>=|<|>|==|!=)(?>\\s*)");
6969
Matcher matcher = operatorPattern.matcher(condition);
7070
if (!matcher.find()) {
7171
infoLogger.warning("Invalid operator: " + condition);
@@ -138,7 +138,7 @@ public boolean created(TagTarget target, PlayerContainer player, String[] argDat
138138
}
139139

140140
private boolean isValidConditionSyntax(String condition) {
141-
Pattern operatorPattern = Pattern.compile("\\s*(<=|>=|<|>|==|!=)\\s*");
141+
Pattern operatorPattern = Pattern.compile("(?>\\s*)(?:<=|>=|<|>|==|!=)(?>\\s*)");
142142
Matcher matcher = operatorPattern.matcher(condition);
143143
if (!matcher.find()) return false;
144144
int operatorStart = matcher.start();

0 commit comments

Comments
 (0)