Decode EF_IMPU/IMPI/DOMAIN empty records as empty, not text
_decode_nai (decode.py) only treated an all-0xFF record as empty.
A record that is a lone identity tag, or a tag with a zero-length
value (e.g. 80 00 + FF erase filler — a standard unused EF_IMPU
record) slipped through to an ascii fallback and rendered as garbage
text (the "Text: �" artifact).
- Treat a lone tag (80 / 81) or tag+zero-length-value (80 00 / 81 00)
as empty.
- Only decode the TLV *value* bytes (UTF-8); never feed the TLV header
or trailing FF filler to the text decoder. Drop the fragile
raw.rstrip(...).decode('ascii','replace') fallback.
Tests: +4 (empty 80 00+FF record, all-FF, real SIP URI, lone tag).
Backend-only; stays on 1.22.0.
This commit is contained in:
1 parent
6887e53144
commit
e4ac80fb34
2 files changed
+40
-8
No files matched your search
@@ -1017,6 +1017,31 @@ class TestFileDecoders(unittest.TestCase):
|
||||
f = _decode_file_data('6f05', b'enru')
|
||||
self.assertEqual(f['languages'], ['en', 'ru'])
|
||||
|
||||
def test_ef_impu_empty_record(self):
|
||||
# EF_IMPU record that is an unused identity: tag 0x80, zero-length
|
||||
# value, FF erase filler. Must be reported empty, NOT decoded as text.
|
||||
from simtrace2_pysniff.server.decode import _decode_file_data
|
||||
f = _decode_file_data('6f04', bytes.fromhex('8000' + 'ff' * 73))
|
||||
self.assertIn('empty', f)
|
||||
self.assertNotIn('text', f)
|
||||
|
||||
def test_ef_impu_all_ff(self):
|
||||
from simtrace2_pysniff.server.decode import _decode_file_data
|
||||
f = _decode_file_data('6f04', b'\xff' * 75)
|
||||
self.assertIn('empty', f)
|
||||
|
||||
def test_ef_impu_sip_uri(self):
|
||||
from simtrace2_pysniff.server.decode import _decode_file_data
|
||||
payload = b'\x80' + bytes([len(b'sip:alice@example.com')]) + b'sip:alice@example.com'
|
||||
f = _decode_file_data('6f04', payload)
|
||||
self.assertEqual(f.get('text'), 'sip:alice@example.com')
|
||||
|
||||
def test_ef_impu_lone_tag(self):
|
||||
# A record containing only the identity tag (no length/value) is empty.
|
||||
from simtrace2_pysniff.server.decode import _decode_file_data
|
||||
f = _decode_file_data('6f04', b'\x80')
|
||||
self.assertIn('empty', f)
|
||||
|
||||
def test_adn(self):
|
||||
from simtrace2_pysniff.server.decode import _decode_file_data
|
||||
f = _decode_file_data('6f3a', bytes.fromhex(
|
||||
|
||||
Reference in new issue
Block a user