Change the conditional to check on the hexString length and what it starts with vs just with what it starts with as a HEX string > 17 should indidcate the string is actual Hexadecimal and likely UTF-16BE, or starting with 003/002B and length >15

This commit is contained in:
Christopher Landwehr
2025-05-22 13:55:50 -04:00
parent 6dd3eb8ea2
commit 5ea71c3ccb

View File

@@ -220,7 +220,10 @@
while ((match = cmglRegex.exec(data)) !== null) {
const index = parseInt(match[1]);
const senderHex = match[2];
const sender = senderHex.startsWith("003") ? this.convertHexToText(senderHex) : senderHex;
// Maximum world wide phone number length is 17, UTF-16BE Hex string comes back at 48+ for US Number, min lenght is 4.
// When 4 digit SMS short code is used the result is a 16 length string (which we then need to check if the sender hex starts with 003 or 002(+))
// This check is probably completley unecessary but I have no data on how the modems behave around the world otherwise.
const sender = senderHex.length > 15 && (senderHex.startsWith('002B') || senderHex.startsWith('003')) ? this.convertHexToText(senderHex) : senderHex;
const dateStr = match[3].replace(/\+\d{2}$/, "");
const date = this.parseCustomDate(dateStr);
if (isNaN(date)) {