qrcodejs icon indicating copy to clipboard operation
qrcodejs copied to clipboard

Code Length OverFlow Error

Open graemejmuir opened this issue 9 years ago • 28 comments

When a string is passed in between 192 and 220 characters long and using correct level H a code Length Overflow appears. This looks like it is caused by the wrong number of RSblocks being allocated. It looks like it is only allocating 132 blocks for Type 15 and CorrectLevel H. This appears to be coming from the value in the RS_BLOCK_TABLE [11,36,12] that is called in getRSBlocks.

graemejmuir avatar Jan 20 '16 02:01 graemejmuir

Ran into this as well with a string 225 characters long.

adnissen avatar Mar 02 '16 20:03 adnissen

it is happening for UTF length b/w 195 and 220 in my case..

lovekeshkulria avatar May 25 '16 12:05 lovekeshkulria

Same problem here. Switching to another QRCode library. It seems this is no more maintened, and no issue were solved in the past year.

fladna9 avatar Feb 08 '17 07:02 fladna9

Which QRCode Library do you switched to?

ToemD avatar Feb 08 '17 07:02 ToemD

Currently trying this : https://neocotic.com/qrious/ Downloaded production version (minified JS). Will be able to test in few minutes :)

fladna9 avatar Feb 08 '17 07:02 fladna9

Canvas is a bit small; but hey, it works where this JS script says overflow whatever. :3

fladna9 avatar Feb 08 '17 07:02 fladna9

For QRious to work, in your HTML body, put : <canvas id="qrcode"></canvas> And put this in the generate QR code function: var divQRCode = document.getElementById("qrcode"); const qr = new QRious({ element: divQRCode, value: "https://keeex.me", size: 500, }); It's nice and works when we have this error on davidshimjs/qrcodejs library. https://neocotic.com/qrious/

fladna9 avatar Feb 08 '17 07:02 fladna9

Got a problem with QRious : the GNU GPL v3 license. So, stuck with this lib. If you're in my situation, i found a workaround. We're doing JSON object QRCodes and trailing spaces before the last } for data to have a longer length, and this is our generation code :

var json = JSON.stringify(obj); if(json.length < 218 && json.length > 191) { json = json.substring(0, json.length-1); var workaround = " "; // 27 spaces workaround = workaround.substring(0, 218-json.length); json += workaround; json += "}"; } var divQRCode = document.getElementById("qrcode"); var qrcode = new QRCode(divQRCode, { width : 200, height : 200}); qrcode.makeCode(json);

fladna9 avatar Feb 08 '17 08:02 fladna9

@ToemD As the author is not doing any pull request/answers here, we fixed this bug on our repository. Clone/download and go. :) https://github.com/KeeeX/qrcodejs

fladna9 avatar Feb 09 '17 07:02 fladna9

@fladna9 thank you!

babybreath avatar Feb 21 '17 06:02 babybreath

@fladna9 thank you,it's helpful

yuu2lee4 avatar Oct 17 '17 11:10 yuu2lee4

@fladna9 Nearly a year later this saved me. Much appreciated.

EiyuuZack avatar Feb 01 '18 12:02 EiyuuZack

@fladna9 thank you very much

Zelenetska avatar Oct 02 '18 08:10 Zelenetska

@ToemD As the author is not doing any pull request/answers here, we fixed this bug on our repository. Clone/download and go. :) https://github.com/KeeeX/qrcodejs

thanks, it solved the problem

itboos avatar Oct 23 '18 09:10 itboos

@itboos

Thank you so much, guys!

DrMerjo avatar Dec 14 '18 08:12 DrMerjo

@fladna9 really thank you

geminiyellow avatar Dec 25 '18 04:12 geminiyellow

Hello @fladna9 .

I just ran into the same error and your fix worked for me. I tried to understand what was causing the issue but I wasn't able to grasp the root cause. Could you please give me a brief explanation of the root cause?

Thanks in advance ~

carlosrijo avatar Oct 07 '19 14:10 carlosrijo

Another workaround may be to decrease correctLevel, e.g.: correctLevel: QRCode.CorrectLevel.L

pvyhnal-generalbytes avatar Nov 15 '19 16:11 pvyhnal-generalbytes

Another workaround may be to decrease correctLevel, e.g.: correctLevel: QRCode.CorrectLevel.L

it works well for me! thx!

JackRo avatar Nov 30 '19 06:11 JackRo

Another workaround may be to decrease correctLevel, e.g.: correctLevel: QRCode.CorrectLevel.L

THX!

rubickecho avatar Jan 07 '20 08:01 rubickecho

@fladna9, awesome fix!

The only thing I needed to change was to import your script in my HTML file: <script type="text/javascript" src="https://cdn.rawgit.com/KeeeX/qrcodejs/master/qrcode.min.js"></script>

rupumped avatar Apr 22 '20 23:04 rupumped

@ToemD As the author is not doing any pull request/answers here, we fixed this bug on our repository. Clone/download and go. :) https://github.com/KeeeX/qrcodejs

Thank a lot :-)

ltxhhz avatar Nov 02 '20 09:11 ltxhhz

@ToemD As the author is not doing any pull request/answers here, we fixed this bug on our repository. Clone/download and go. :) https://github.com/KeeeX/qrcodejs

Thanks so much 🙂

davechristian avatar May 31 '22 16:05 davechristian

Another workaround may be to decrease correctLevel, e.g.: correctLevel: QRCode.CorrectLevel.L

It solved the problem for me as well. Thank you!

yvomenezes avatar Apr 12 '23 14:04 yvomenezes

@ToemD As the author is not doing any pull request/answers here, we fixed this bug on our repository. Clone/download and go. :) https://github.com/KeeeX/qrcodejs

Thanks! Saved my bacon!

JussiKauhanen avatar Nov 01 '23 15:11 JussiKauhanen

@fladna9 in heaven there's a place for you :D

artulance avatar Mar 06 '24 14:03 artulance