From 97d86c95716c9118eefade0ba2ebe18ba545905c Mon Sep 17 00:00:00 2001 From: Dmitry Monakhov Date: Tue, 23 Jun 2026 09:52:33 +0200 Subject: [PATCH] Fix BBQr share of Unicode text: encode str to UTF-8 before sizing/splitting For 'U'/'J' payloads data is a str; planning counted codepoints while b32encode consumes UTF-8 bytes, so multi-byte text (e.g. paper-wallet QR art) overflowed target_vers and tripped the assert in show_bbqr_codes. --- shared/ux_q1.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/shared/ux_q1.py b/shared/ux_q1.py index 2224b934..c36018fe 100644 --- a/shared/ux_q1.py +++ b/shared/ux_q1.py @@ -1215,6 +1215,11 @@ async def show_bbqr_codes(type_code, data, msg, already_hex=False): else: # default to Base32, because always best option encoding = '2' + if isinstance(data, str): + # 'U'/'J' payloads are UTF-8 text; b32encode consumes the UTF-8 + # bytes, so convert now to keep length/slicing consistent (else + # multi-byte chars overflow target_vers -> assert below trips) + data = data.encode() data_len = len(data) # try a few select resolutions (sizes) in order such that we use either single QR