From ac6d391376924e712ae1084b4bd67a0c6f720788 Mon Sep 17 00:00:00 2001 From: Gav Date: Wed, 12 Apr 2017 13:12:53 +0200 Subject: [PATCH] Fix buffer length for QR code gen. --- js/src/ui/QrCode/qrSize.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/js/src/ui/QrCode/qrSize.js b/js/src/ui/QrCode/qrSize.js index 2671bb53269..8440458acb1 100644 --- a/js/src/ui/QrCode/qrSize.js +++ b/js/src/ui/QrCode/qrSize.js @@ -69,7 +69,9 @@ const QR_SIZES = [ export function calculateType (lengthBytes, errorLevel = 'M') { let type = 5; - while (type < 40 && lengthBytes > QR_SIZES[errorLevel][type - 1]) { + // subtract 3 from the capacities, since we need 2 bits for the mode and a + // bunch more for the length. + while (type < 40 && lengthBytes > QR_SIZES[errorLevel][type - 1] - 3) { type++; }