docker-minecraft-server: MOTD Sanitization Breaks Color Coding (using section mark symbol)

The code around line 25 of scripts/start-setupServerProperties sanitizes the MOTD text, but that causes it to be entirely broken if it contains color or other speciak formatting. All section marks (§, the character used by Minecraft as an escape character for processing formatting) are replaced with § which seems to be something to do with UTF-8 vs UTF-16 encoding. However, this causes text to look very wrong in game, as seen in the image below. Here is an example of what I mean:

This MOTD is supposed to make rainbow text that says “Testing 123”:

§c§lT§6§le§e§ls§a§lt§3§li§9§ln§5§lg §6§l1§e§l2§a§l3

However, it gets converted to the following:

§c§lT§6§le§e§ls§a§lt§3§li§9§ln§5§lg §6§l1§e§l2§a§l3

In game, it appears like this: image

About this issue

  • Original URL
  • State: closed
  • Created 9 months ago
  • Comments: 26 (14 by maintainers)

Most upvoted comments

Thanks for confirming the latest changes @aaronjamt and @LapinFou

Currently building image should fix the latest scenario you confirmed. I’ll create a follow up change to also write-out the file with UTF-8 encoding rather than escaping the Unicode characters.

…it also doesn’t help that the Minecraft server is re-writing the server.properties file. IMHO it should be only reading that file and not modifying it.

Yeah, I agree. I think the logic is that allowing the server to modify it, it can “correct” certain options (for instance, convert the difficulty= from the legacy 1/2/3 numeric values to the new easy/normal/hard text format), but I feel like the server should just log a warning that says [WARN] Difficulty setting in server.properties uses legacy format (currently set to 1). Please change to "easy" instead., or something along those lines.

Can you double check that you have the latest image re-pulled? I tried a few more experiments and the only way I could “break” it was to set MOTD to the pre-escaped version

      MOTD: \u00A7c\u00A7lT\u00A76\u00A7le\u00A7e\u00A7ls\u00A7a\u00A7lt\u00A73\u00A7li\u00A79\u00A7ln\u00A75\u00A7lg \u00A76\u00A7l1\u00A7e\u00A7l2\u00A7a\u00A7l3

and it would double escape the backslashes:

image

I’ll see if I can address that, but I know that’s different than your scenario.