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.
This commit is contained in:
Dmitry Monakhov 2026-06-23 09:52:33 +02:00 committed by doc-hex
parent edae8c1ee6
commit 97d86c9571

View File

@ -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