pranomostro / ratox

[wip] fifo based tox client
http://ratox.2f30.org/
ISC License
20 stars 2 forks source link

Empty messages fail #21

Closed pranomostro closed 7 years ago

pranomostro commented 7 years ago
echo '' >text_in
Failed to send message
z3bra commented 7 years ago

toxcore doesn't accept messages with a length of 0. echo actually writes 1 char: \n. It is thus a 1 char message for ratox. For each message sent, we trim the trailing \n, then send the message. In this special case, an initial message which is 1 byte long gets sent as being 0 byte long, triggering the error. We need to perform the lenght check AFTER trimming the line feed in sendfriendtext(). This should be an easy fix.

z3bra commented 7 years ago

The following patch fixes this issue by sending the \n if it's alone. In this case we assume the user wanted to send a single line feed, for example is order to "clean" the screen or something like that. It's only a proposal as such a behavior means we're treating a single \n with a special meaning, which might not be a wanted behavior. In such a case, the fix would be totally differnet.

pranomostro commented 7 years ago

We can use IRC or tox or whatever, I know you don't like github.

I think we should add the special behaviour for \n, because I would like it to behave similar to IRC, where an \n is valid.

pranomostro commented 7 years ago

Applied your patch.