NuSkooler / enigma-bbs

ENiGMA½ BBS Software
https://nuskooler.github.io/enigma-bbs/
BSD 2-Clause "Simplified" License
537 stars 104 forks source link

mrc_multiplexer.js errors out when URL is pasted in MRC chat #551

Closed voipmeister closed 1 month ago

voipmeister commented 1 month ago

Describe the Bug Enigma crashes when a URL is pasted in the MRC chat.

To Reproduce Log onto MRC from Enigma 0.0.14, have someone paste for instance: https://twitch.tv/the_meatlotion, from a Mystic board (probably any UTF-8 client). In this case it was Meatlotion.

Expected Behavior Proper sanitation, no crash. Other chatters had no issue in the same chat, but they use different clients obviously.

Actual Behavior Enigma crashes:

ENiGMA½ Copyright (c) 2015-2024, Bryan D. Ashby
_____________________   _____  ____________________    __________\_   /
/____       _____|      __________       ___|__|      ____|     \   /  _____  \
---- \______\ -- |______\ ------ /______/ ---- |______\ - |______\ /__/ // ___/
                                                                     /__   _\
 <*>   ENiGMA½  // HTTPS://GITHUB.COM/NUSKOOLER/ENIGMA-BBS   <*>       /__/

-------------------------------------------------------------------------------

System started!
/home/enigma/enigma-bbs/core/servers/chat/mrc_multiplexer.js:249
                message.to_user.toUpperCase() == client.username.toUpperCase() ||
                                ^

TypeError: Cannot read properties of undefined (reading 'toUpperCase')
    at /home/enigma/enigma-bbs/core/servers/chat/mrc_multiplexer.js:249:33
    at Set.forEach (<anonymous>)
    at MrcModule.sendToClient (/home/enigma/enigma-bbs/core/servers/chat/mrc_multiplexer.js:245:26)
    at MrcModule.receiveFromMRC (/home/enigma/enigma-bbs/core/servers/chat/mrc_multiplexer.js:323:18)
    at /home/enigma/enigma-bbs/core/servers/chat/mrc_multiplexer.js:157:30
    at Array.forEach (<anonymous>)
    at handleData (/home/enigma/enigma-bbs/core/servers/chat/mrc_multiplexer.js:153:19)
    at TLSSocket.<anonymous> (/home/enigma/enigma-bbs/core/servers/chat/mrc_multiplexer.js:164:13)
    at TLSSocket.emit (node:events:517:28)
    at addChunk (node:internal/streams/readable:368:12)

Node.js v18.20.4
[enigma@node01 enigma-bbs]$

Screenshots N/a.

Environment

voipmeister commented 1 month ago

ML and I have been testing some more, and the above happens when the MRC server URL shortener kicks in. It 'works' both ways:

This is observed with Enigma 0.0.14, we also tested with 0.0.10 and that version is immune to the problem.

For argument's sake we also tested with 3 clients in total, where the 3rd client was in another channel sending a link that got shortened, that did not trigger the problem for me on v0.0.14.

voipmeister commented 1 month ago

Testing a bit more, when commenting the middle line below (line 249 in mrc_multiplexer.js), the problem is gone. However, it prevents private messages from being sent.

                // Fix PrivMSG delivery on case mismatch
                //message.to_user.toUpperCase() == client.username.toUpperCase() ||
                message.to_user == 'CLIENT' ||
stack-fault commented 1 month ago

This issue is resolved with the PR merged

voipmeister commented 1 month ago

Closed, as resolved in #552