PhantomSDR Support Forum

General Category => PhantomSDR Bugs => Topic started by: Bas ON5HB on Mar 13, 2025, 08:11 AM

Title: Chatbox crash again....
Post by: Bas ON5HB on Mar 13, 2025, 08:11 AM
We have to do something about the chatbox as some people put special characters in it and it crashes.

It does write the special characters, but can't read them.

We had this before.

Looks to me the problem is @HTML for messages? As they are able to put smileys in their chatmessage.
It is written in the chat-file, as I saw them. However, it makes the spectrumserver crash with a websocket error.

Seems to me we need to check the imput of users before it goes to the chatbox and file, as once written the spectrumserver crash and won't restart until the smileys are removed from the chatbox-file.
Title: Re: Chatbox crash again....
Post by: Phil - NY4Q on Mar 14, 2025, 12:41 PM
I modded the sendMessage() function in App.svelte to what is below and it seems to be working. After further testing, I will add it to the App.svelte.

function sendMessage() {
    newMessage = newMessage.replace(/[^\x00-\x7F]/g, ""); // Strips non-ASCII
    if (newMessage.trim() && username.trim()) {
      const messageObject = {
        cmd: "chat",
        message: newMessage.trim(),
        username: username,
      };
      socket.send(JSON.stringify(messageObject));
      newMessage = "";
      scrollToBottom();
    }
  }
Title: Re: Chatbox crash again....
Post by: Bas ON5HB on Mar 16, 2025, 04:27 PM
Nice.
Title: Re: Chatbox crash again....
Post by: Andy R3MAV on May 21, 2025, 01:42 PM
Quote from: Phil - NY4Q on Mar 14, 2025, 12:41 PMI modded the sendMessage() function in App.svelte
Phil, didn't these changes disable the ability to write not only in Latin? I try to write messages in Cyrillic and nothing is sent to the chat.
It's very disappointing. I want to use the chat, but it doesn't work.
Title: Re: Chatbox crash again....
Post by: Bas ON5HB on May 21, 2025, 03:14 PM
You can't strip non-ASCII, if you do non ACSII won't be accepted.

Are you sure the chatbox is crashing? As I modified the spectrum-server and since my server didn't crash.

I found that the buffer messages make it crash.

Maybe you have the same problem and it's NOT the chatbox, as I had weird crashes...some looked like the chatbox.

https://www.phantomsdr.fun/index.php?topic=182.msg1060#msg1060
Title: Re: Chatbox crash again....
Post by: Bas ON5HB on May 28, 2025, 04:56 PM
Well my chatbox crashed again because some morron used smileys again.

Lets try the fix.

Starting to hate the chatbox in total :'(
Title: Re: Chatbox crash again....
Post by: Bas ON5HB on Jun 04, 2025, 03:10 PM
Quote from: Phil - NY4Q on Mar 14, 2025, 12:41 PMI modded the sendMessage() function in App.svelte to what is below and it seems to be working. After further testing, I will add it to the App.svelte.

function sendMessage() {
    newMessage = newMessage.replace(/[^\x00-\x7F]/g, ""); // Strips non-ASCII
    if (newMessage.trim() && username.trim()) {
      const messageObject = {
        cmd: "chat",
        message: newMessage.trim(),
        username: username,
      };
      socket.send(JSON.stringify(messageObject));
      newMessage = "";
      scrollToBottom();
    }
  }


It seems to remove too much, so I changed the filter to UNICODE. Testing at the moment:

newMessage = newMessage.replace(/[\u{33F0}-\u{FFFF}]/gu, ""); // Strips new version ON5HB - Unicode
As several people complained they can't use German characters. Hopefully Unicode solves this.

https://en.wikipedia.org/wiki/List_of_Unicode_characters

Hopefully no more weird stuff but all unicode accepted.
Title: Re: Chatbox crash again....
Post by: Phil - NY4Q on Jun 12, 2025, 12:51 PM
Bas' new technique for the chatbox is now added to the current git App.svelte.