Color-code SW in APDU list + fix empty ISIM record decode

- SW column now shows green (success 90/92-9F), blue (pending 61/91/6C),
  amber (warning 62/63), red (error 64-6F) per ISO 7816-4 / TS 102 221.
- _decode_nai: treat all-FF records as empty instead of emitting
  replacement characters; strip FF padding before the ASCII fallback.
This commit is contained in:
catarrh committed 2026-08-16 13:22:01 +03:00
1 parent 747974460e
commit 35067f8d9d
3 files changed
+33 -2

No files matched your search

+3 -1
View File
@@ -2213,6 +2213,8 @@ def _decode_phase(raw, p1=None):
def _decode_nai(raw, p1=None):
"""ISIM identity files (EF_IMPI/DOMAIN/IMPU): BER-TLV tag 0x80 + ASCII value."""
if not raw or all(b == 0xff for b in raw):
return {'empty': True}
texts = []
for tag, _length, value in parse_tlv(raw):
if tag == 0x80:
@@ -2221,7 +2223,7 @@ def _decode_nai(raw, p1=None):
texts.append(txt)
if texts:
return {'text': texts[0] if len(texts) == 1 else ', '.join(texts)}
txt = raw.decode('ascii', 'replace').replace('\xff', '').strip()
txt = raw.rstrip(b'\xff').decode('ascii', 'replace').strip()
return {'text': txt} if txt else {'raw': raw.hex().upper()}