diff --git a/src/Main.java b/src/Main.java index f3d90b7..f1fb25e 100644 --- a/src/Main.java +++ b/src/Main.java @@ -103,10 +103,10 @@ class Main { * @return The wanted substring. */ private static String stringBetween(String string, String start, String end) { - if (!string.contains(start)) { + int startPos = string.indexOf(start) + start.length(); + if (!string.contains(start) || string.indexOf(end, startPos) < startPos) { return ""; } - int startPos = string.indexOf(start) + start.length(); return string.substring(startPos, string.indexOf(end, startPos)); } } \ No newline at end of file diff --git a/src/net/knarcraft/serverlauncher/server/Server.java b/src/net/knarcraft/serverlauncher/server/Server.java index 57a57ca..39aaa65 100644 --- a/src/net/knarcraft/serverlauncher/server/Server.java +++ b/src/net/knarcraft/serverlauncher/server/Server.java @@ -350,10 +350,10 @@ public class Server { * @return The wanted substring. */ private static String stringBetween(String string, String start, String end) { - if (!string.contains(start)) { + int startPos = string.indexOf(start) + start.length(); + if (!string.contains(start) || string.indexOf(end, startPos) < startPos) { return ""; } - int startPos = string.indexOf(start) + start.length(); return string.substring(startPos, string.indexOf(end, startPos)); }