You've already forked Arcturus-Morningstar-Extended
mirror of
https://github.com/duckietm/Arcturus-Morningstar-Extended.git
synced 2026-06-19 15:06:19 +00:00
fix(items): Locale.ROOT case-folding + document sanitize cap unit + tighten cap test
This commit is contained in:
@@ -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));
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user