Skip to content

Commit 267051e

Browse files
committed
Safe check condition patterns
1 parent 0014662 commit 267051e

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

changelog.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
- Support conditional reconnecting
2-
- Use YACL in place of Cloth Config
1+
- Safe check condition patterns

common/src/main/java/dev/terminalmc/autoreconnectrf/mixin/MixinDisconnectedScreens.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import java.util.NoSuchElementException;
2727
import java.util.concurrent.TimeUnit;
2828
import java.util.regex.Pattern;
29+
import java.util.regex.PatternSyntaxException;
2930

3031
import net.minecraft.ChatFormatting;
3132
import net.minecraft.client.Minecraft;
@@ -64,11 +65,16 @@ private void init(CallbackInfo info) {
6465
boolean match = false;
6566

6667
for (String condition : Config.get().options.conditionPatterns) {
67-
if (Pattern.compile(condition).matcher(reasonStr).find()) {
68-
AutoReconnect.LOG.info("Matched pattern '{}' against reason '{}'",
69-
condition, reasonStr);
70-
match = true;
71-
break;
68+
try {
69+
if (Pattern.compile(condition).matcher(reasonStr).find()) {
70+
AutoReconnect.LOG.info("Matched pattern '{}' against reason '{}'",
71+
condition, reasonStr);
72+
match = true;
73+
break;
74+
}
75+
} catch (PatternSyntaxException e) {
76+
AutoReconnect.LOG.error(String.format("Invalid pattern: %s\n%s", condition,
77+
e.getMessage()));
7278
}
7379
}
7480
if (!match && reason.getContents() instanceof TranslatableContents tc) {

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Neo/Forge version ranges: https://maven.apache.org/enforcer/enforcer-rules/versionRanges.html
33

44
# Project
5-
mod_version=0.2.0
5+
mod_version=0.3.0
66
mod_group=dev.terminalmc
77
mod_id=autoreconnectrf
88
mod_name=AutoReconnect-Reforged

0 commit comments

Comments
 (0)