From e7de4e1a10aa66d4ef8f7992d5f25e9af691ebca Mon Sep 17 00:00:00 2001 From: Cardillan <122014763+cardillan@users.noreply.github.com> Date: Wed, 30 Sep 2026 23:55:18 +0200 Subject: [PATCH] Fix empty statement fields shifting the remaining parameters (#12715) * Fix empty statement fields shifting remaining parameters * Fixed unit tests --- core/src/mindustry/logic/LStatement.java | 2 +- tests/src/test/java/LogicTests.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/mindustry/logic/LStatement.java b/core/src/mindustry/logic/LStatement.java index a0d7c71dad..69229fc275 100644 --- a/core/src/mindustry/logic/LStatement.java +++ b/core/src/mindustry/logic/LStatement.java @@ -90,7 +90,7 @@ public abstract class LStatement{ /** Sanitizes variable input strings from text fields into values that will not break logic parsing. */ public static String sanitize(String value){ if(value.length() == 0){ - return ""; + return "null"; }else if(value.length() == 1){ if(value.charAt(0) == '"' || value.charAt(0) == ';' || value.charAt(0) == ' ' || value.charAt(0) == '\n' || value.charAt(0) == '\t' || value.charAt(0) == '#'){ diff --git a/tests/src/test/java/LogicTests.java b/tests/src/test/java/LogicTests.java index 140145398a..3265834ff8 100644 --- a/tests/src/test/java/LogicTests.java +++ b/tests/src/test/java/LogicTests.java @@ -123,7 +123,7 @@ public class LogicTests{ Arguments.of("a bare single semicolon is invalid", ";", "invalid"), Arguments.of("a bare single space is invalid", " ", "invalid"), Arguments.of("a single ordinary character passes through unchanged", "a", "a"), - Arguments.of("empty input stays empty", "", ""), + Arguments.of("empty input gets converted to null", "", "null"), Arguments.of("a plain already-quoted value is untouched", "\"hello\"", "\"hello\""), Arguments.of("a unescaped quote at the end gets doubled", "\"hello\\\"", "\"hello\\\\\""), Arguments.of( @@ -454,4 +454,4 @@ public class LogicTests{ void crlfLabelsResolveToTheSameJumpLocationAsLfLabels(){ assertDoesNotThrow(() -> load("loop:\r\njump loop always\r\n")); } -} \ No newline at end of file +}