[SPIGOT-7676] Issues with locale-specific string conversions (e.g. toLowercase()) Created: 31/May/24  Updated: 25/Dec/24  Resolved: 02/Jun/24

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: blablubbabc Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: item, locale, serialization

Version: This server is running CraftBukkit version dev-Spigot-864e4ac-c8b4da8 (MC: 1.20.4) (Implementing API version 1.20.4-R0.1-SNAPSHOT)
Guidelines Read: Yes

 Description   

We are using the locale-specific `toLowercase()` in a few places in both Bukkit and CraftBukkit. This can result in unexpected results for certain locales, such as turkish (tr-TR), which handles lowercase for the `I` character a bit differently. For example, in 1.20.4, the config deserialization of any item enchantments containing an `I` in their name was broken (I noticed it for the `PIERCING` enchantment).

Log.severe("Piercing enchantment name lowercase: " + Enchantment.PIERCING.getName().toLowerCase());
Log.severe("Piercing enchantment found?: " + Enchantment.getByName(Enchantment.PIERCING.getName()))

yields

Piercing enchantment name lowercase: pıercıng
Piercing enchantment found?: null

This no longer the case in 1.20.6 due to deserialization changes, but similar issues might likely still affect us in a few other places currently. For example:

  • The deprecated Enchantment.getByName (in case any plugin still uses it directly)
  • AttributeModifier deserialization: There are EquipmentSlotGroups that have an I in their name.
  • Registry.match(String)
  • WarningState.Value(String) (might not be affected currently, at least not or the turkish language, because they don't contain any "I" character).
  • TODO Not sure yet if StringUtil.startsWithIgnoreCase is affected, which might impact tab completion of commands.
  • TODO: Similar, there are quite a few uses in CraftBukkit.

TODO: Still need to check for and test more examples in which this might currently still be an issue.



 Comments   
Comment by md_5 [ 01/Jun/24 ]

At some point this was fixed across the codebase, but I guess new ones have slipped in

Generated at Sun Mar 16 22:57:14 UTC 2025 using Jira 10.3.3#10030003-sha1:d220e3fefc8dfc6d47f522d3b9a20c1455e12b7b.