FIX: Messages with IDs starting with 66 and 67 #1224
Closed
+2
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🇧🇷 🇧🇷 🇧🇷 🇧🇷 🇧🇷
Pull Request: Fixing encodeBinaryNode in Whiskeysockets
Problem Description
The
encodeBinaryNode
method in the Whiskeysockets library had a bug in thewriteString
function. The issue stemmed from an incorrect order of type checks, causing strings that should be encoded as text to be misinterpreted as hexadecimal.Problematic Behavior
The
isHex(str)
check inwriteString
occurred before decoding as a JID or falling back towriteStringRaw(str)
. As a result, strings with hexadecimal-like characters were treated as hex values, producing malformed nodes.This affected the
sendMessageAck
function, which generates and sends acknowledgment nodes. Malformed nodes were not recognized by recipients, resulting in infinite resends and message flow blockages.Example received message triggering the bug:
Malformed ACK node sent:
Solution Implemented
The
writeString
function was updated to ensure:TOKEN_MAP
are prioritized.writeStringRaw
.Updated
writeString
implementation:Benefits
sendMessageAck
.Tests Performed
Tests included:
66
and67
.All tests confirmed correct ACK formatting and server acceptance without retries.
Conclusion
This PR resolves a critical encoding issue in
encodeBinaryNode
, ensuring reliable and efficient message handling. It eliminates malformed ACK nodes and improves library stability and communication performance.THANKS to Renato (https://github.com/renatoiub) for providing me with numbers that send this type of message for testing.