File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed
Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change 3232 dub build
3333
3434 - name : Upload
35- uses : actions/upload-artifact@v3
35+ uses : actions/upload-artifact@v4
3636 with :
3737 name : build-${{matrix.os}}
3838 path : ${{github.workspace}}/mcyeti*
Original file line number Diff line number Diff line change @@ -208,6 +208,20 @@ class Client : Player {
208208 outBuffer ~= identification.CreateData();
209209 }
210210
211+ private bool ValidateUsername (string username) {
212+ if (username.length < 2 || username.length > 16 ) return false ;
213+
214+ for (int i = 0 ; i < username.length; i++ ) {
215+ char current = username[i];
216+ if (current == ' _' || current == ' .' ) continue ;
217+ if (current >= ' 0' && current <= ' 9' ) continue ;
218+ if ((current >= ' a' && current <= ' z' ) || (current >= ' A' && current <= ' Z' )) continue ;
219+ return false ;
220+ }
221+
222+ return true ;
223+ }
224+
211225 void Update (Server server) {
212226 auto time = Clock .currTime().toUnixTime();
213227
@@ -234,6 +248,11 @@ class Client : Player {
234248 packet.FromData(inBuffer);
235249 inBuffer = inBuffer[packet.GetSize() .. $];
236250
251+ if (! ValidateUsername(packet.username)) {
252+ server.Kick(this , " Bad username" );
253+ return ;
254+ }
255+
237256 auto correctMppass = md5Of(
238257 server.salt ~ packet.username
239258 ).BytesToString();
@@ -306,7 +325,6 @@ class Client : Player {
306325
307326 if (muted) {
308327 SendMessage(" &eYou are muted" );
309- return ;
310328 }
311329
312330 server.SendGlobalMessage(
You can’t perform that action at this time.
0 commit comments