diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/FurnitureTextProvider.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/FurnitureTextProvider.java index 634b8be0..43966984 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/FurnitureTextProvider.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/FurnitureTextProvider.java @@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Map; /** @@ -47,11 +48,16 @@ public class FurnitureTextProvider { if (classname == null) return null; int star = classname.indexOf('*'); String base = (star >= 0) ? classname.substring(0, star) : classname; - base = base.trim().toLowerCase(); + base = base.trim().toLowerCase(Locale.ROOT); return base.isEmpty() ? null : base; } - /** Cap length, strip control chars/newlines, neutralize % (placeholder-injection safe). */ + /** + * Cap length, strip control chars/newlines, neutralize % (placeholder-injection safe). + * The 256 cap is in Java {@code char} units (UTF-16 code units), which is acceptable for + * furni names (controlled, predominantly ASCII source). Lone/astral surrogates are not + * specially handled. + */ static String sanitize(String value) { if (value == null) return ""; StringBuilder sb = new StringBuilder(Math.min(value.length(), MAX_LEN)); diff --git a/Emulator/src/test/java/com/eu/habbo/habbohotel/items/FurnitureTextProviderTest.java b/Emulator/src/test/java/com/eu/habbo/habbohotel/items/FurnitureTextProviderTest.java index 5e510071..4c8fd2a9 100644 --- a/Emulator/src/test/java/com/eu/habbo/habbohotel/items/FurnitureTextProviderTest.java +++ b/Emulator/src/test/java/com/eu/habbo/habbohotel/items/FurnitureTextProviderTest.java @@ -47,7 +47,7 @@ class FurnitureTextProviderTest { FurnitureTextProvider p = provider(true, new FurnidataEntry(1, "x", FurnitureType.FLOOR, evil, "")); String name = p.getName("x"); - assertTrue(name.length() <= 256, "must be capped to 256"); + assertEquals(256, name.length(), "input far exceeds the cap, so it must be exactly 256"); assertFalse(name.chars().anyMatch(Character::isISOControl), "no control chars remain after sanitize"); assertFalse(name.contains("%"), "ASCII percent neutralized"); }