File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed
Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change 77
88from ..exceptions import SignalduinoParserError
99
10- _STX_ETX = re .compile (r"^\x02(M[s|u|o ];.*;)\x03$" )
10+ _STX_ETX = re .compile (r"^\x02(M[sSuUcCNOo ];.*;)\x03$" )
1111
1212
1313def decompress_payload (compressed_payload : str ) -> str :
@@ -16,7 +16,23 @@ def decompress_payload(compressed_payload: str) -> str:
1616
1717 The Perl logic is in 00_SIGNALduino.pm around line 1784.
1818 """
19- if not compressed_payload .upper ().startswith (("MS;" , "MU;" , "MO;" )):
19+ # Check if the message is actually compressed (contains high-bit chars)
20+ # The Perl logic runs a decompression loop on any MS/MU/MO, but the compression
21+ # logic only works if high-bit chars are present, otherwise it mangles standard fields.
22+ # We will only run decompression if we detect at least one high-bit character (ord > 127)
23+ # in any part that is not the header (first 3 chars).
24+ if not compressed_payload .upper ().startswith (("MS;" , "MU;" , "MO;" , "MN;" )):
25+ return compressed_payload
26+
27+ # Check for compression marker (a character with high-bit set)
28+ is_compressed = False
29+ if len (compressed_payload ) > 3 :
30+ for char in compressed_payload [3 :]:
31+ if ord (char ) > 127 :
32+ is_compressed = True
33+ break
34+
35+ if not is_compressed :
2036 return compressed_payload
2137
2238 # Split message parts by ';'
You can’t perform that action at this time.
0 commit comments