Fix message encode crash, DCS-aware decode, and user-defined TLV round-trip#261
Open
fdciabdul wants to merge 1 commit into
Open
Fix message encode crash, DCS-aware decode, and user-defined TLV round-trip#261fdciabdul wants to merge 1 commit into
fdciabdul wants to merge 1 commit into
Conversation
fix: message encode crash, DCS-aware decode, user-defined TLV round-trip - farhadi#229/farhadi#256: tolerate non-string short_message (number/null/undefined) in the message encode filter instead of throwing "Cannot read properties of undefined (reading message)" - farhadi#66/farhadi#252: resolve decode charset from the full Data Coding Scheme byte (GSM 03.38 message-class / MWI groups) instead of the naive low-nibble mask - farhadi#231: user-defined / unknown TLVs addressed by numeric tag id now round-trip on encode (PDU constructor + toBuffer), not only on decode Adds regression tests (test/fixes.js). @
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
@
This PR fixes three independent, frequently-reported issues. Each change is small and covered by a regression test (
test/fixes.js). No API changes.short_messageencode crash — fixes #229, #256filters.message.encodeassumed a string or{message}object and threwTypeError: Cannot read properties of undefined (reading message)when given anumber,
null, orundefinedshort_message. It now coerces scalars and guardsnull/undefined.
Wrong/empty decode for high Data Coding Scheme values — fixes #66, #252
Decoding used
data_coding & 0x0F, which mis-detects the charset whenever the DCShigh nibble carries message-class / MWI / compression bits (GSM 03.38). Decoding
now parses the full DCS byte. Low
data_codingvalues (0x00–0x0E) are unchanged.User-defined TLVs not sent — fixes #231
Unknown/custom TLVs addressed by their numeric tag id (e.g.
pdu[0x3C02] = Buffer.from(...))were parsed on decode but silently dropped on encode. They now round-trip: the PDU
constructor keeps numeric-tag keys and
toBuffer()writes them.Tests
Adds
test/fixes.js. All existing tests still pass (the only failure in CI-lesslocal runs is the pre-existing network-dependent invalid-host DNS test).
These fixes are also available, alongside a full TypeScript rewrite (dual ESM+CJS,
types, Bun support) and more features, in the maintained fork
https://github.com/fdciabdul/node-smpp-next — but this PR intentionally keeps the
changes minimal and JS-only for easy review/merge here.
@