[SPIGOT-1220] Query: utf-8 players' names Created: 03/Oct/15  Updated: 03/Oct/15  Resolved: 03/Oct/15

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

Type: Bug Priority: Minor
Reporter:   Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: utf-8, vanilla
Environment:

Does not matter.



 Description   

Steps to reproduce:
1. Switch "enable-query" to true, "online-mode" to false
2. Start the server.
3. Log in under some non-ASCII name, for example "игрок" (non-official launcher).
4. Connect to server, it will handle your name correctly as any other utf-8 name.
5. Query the server, for example, with PHP-Source-Query (https://github.com/xPaw/PHP-Source-Query).
6. Discover that instead "игрок" server query says that there is a player with some strange nick like "B3J@U".
================
Expected output:
Server query returns "игрок"
================
Real output:
Server query returns "B3J@U"
================
Explanation:
There is a class net.minecraft.server.v1_8_R3.RemoteStatusListener. A method "private byte[] b(DatagramPacket var1)" is responsible for forming return string for query. There are strings "
for(String p: this.b.getPlayers())

{ this.v.a(p); }

", responsible for forming player list. "this.v.a(String str)" leads to "this.stream.writeBytes(b);" what leads to function contains "out.write((byte)s.charAt)". But not all chars can be converted to byte without losses! Some, non-ASCII, are losing senior bits what leads to unrecoverable data loss.
================
Fix:
Replace "this.v.a(p);" to "this.v.a(p.getBytes(Charset.forName("UTF-8")));this.v.a("");" in net.minecraft.server.v1_8_R3.RemoteStatusListener class.
After that RemoteStatusListener handles utf-8 players' names correctly. Tested, works.
================
It is expected that new patch will be added to the SPIGOT project.



 Comments   
Comment by md_5 [ 03/Oct/15 ]

Closing was won't fix because:

  1. Mojang Issue
  2. Offline mode
  3. No backwards compatible fix
Comment by md_5 [ 03/Oct/15 ]

I think it is expected however that the output of this service is ASCII. Given that Mojang doesn't allow UTF-8 names, changing this services to use UTF-8 might break other services already legitimately relying on it being ASCII.

Comment by SpigotMC [ 03/Oct/15 ]

Your build is not the latest and therefore may be the reason you are having this issue. Spigot is 0 version(s) behind. CraftBukkit is 2 version(s) behind. This message was automatically generated and is not guaranteed to be a solution to your issue.

Generated at Tue Apr 15 09:10:41 UTC 2025 using Jira 10.3.3#10030003-sha1:d220e3fefc8dfc6d47f522d3b9a20c1455e12b7b.