Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-7676

Issues with locale-specific string conversions (e.g. toLowercase())

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • This server is running CraftBukkit version dev-Spigot-864e4ac-c8b4da8 (MC: 1.20.4) (Implementing API version 1.20.4-R0.1-SNAPSHOT)
    • Yes

      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.

            Unassigned Unassigned
            blablubbabc blablubbabc
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: