Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qrcode.makeCode() still has Code Length OverFlow Error #1

Closed
suxiaogang opened this issue May 24, 2018 · 8 comments
Closed

qrcode.makeCode() still has Code Length OverFlow Error #1

suxiaogang opened this issue May 24, 2018 · 8 comments
Assignees
Labels

Comments

@suxiaogang
Copy link

Come form https://github.com/davidshimjs/qrcodejs/issues/78 and firstly thanks for you awesome fork for the original repo.
it seems that qrcode.makeCode() still has this issue. please do a further job, thank you.

@fladna9
Copy link

fladna9 commented May 24, 2018

Hello @suxiaogang.
I need more information about your problem. What is the length (eventually content if not private) of the QR Code you're trying to generate ?
Did you try any other correctLevel parameter ?

@suxiaogang
Copy link
Author

suxiaogang commented May 24, 2018

emmmmm.... after investigation this might be related to character encoding ...
actually I'm try to qrcode some string which contains Chinese

var QRCodeBox = new QRCode(document.getElementById("qr"), {
    width: 200,
    height: 200,
    correctLevel: QRCode.CorrectLevel.H
});
var str = "ed2k://|file|【电影家园www.idyjy.com下载】寂静之地.HD韩版中英双字.mp4|1129787457|AD3BD4384712D52D2BB09A150AF64D55|h=BMZZS7VBJ4ZAROGOU56245LCBBO6DRO7|/";
QRCodeBox.makeCode(str);

@fladna9 well you can close this issue if it is confirmed to be a encoding problem.

@fladna9
Copy link

fladna9 commented May 24, 2018

Strange. Got this on Chrome Version 66.0.3359.181 (Official build) (64 bits) on macOS, no warnings/errors in JS console...
Will try in Firefox and Safari.
telechargement

@suxiaogang
Copy link
Author

suxiaogang commented May 24, 2018

Chrome/65.0.3325.181 & Mac OS X 10_13_4, everytime

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
</head>
<body class="chrome-popup">
<div style="width:100%;margin:35px;" id="qr"></div>
<script src="http://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
<!--replace below with your forked file-->
<script src="https://raw.githubusercontent.com/KeeeX/qrcodejs/master/qrcode.min.js"></script>
</body>
<script>
$(document).ready(function() {
  var QRCodeBox = new QRCode(document.getElementById("qr"), {
      width: 200,
      height: 200,
      correctLevel: QRCode.CorrectLevel.H
  });
  var str = "ed2k://|file|【电影家园www.idyjy.com下载】寂静之地.HD韩版中英双字.mp4|1129787457|AD3BD4384712D52D2BB09A150AF64D55|h=BMZZS7VBJ4ZAROGOU56245LCBBO6DRO7|/";
  QRCodeBox.makeCode(str);
});
</script>
</html>
qrcode.min.js:1 Uncaught Error: code length overflow. (3004>1440)
    at Function.b.createData (qrcode.min.js:1)
    at b.makeImpl (qrcode.min.js:1)
    at b.getBestMaskPattern (qrcode.min.js:1)
    at b.make (qrcode.min.js:1)
    at QRCode.makeCode (qrcode.min.js:1)
    at HTMLDocument.<anonymous> (test.html:22)
    at i (jquery.min.js:2)
    at Object.fireWith [as resolveWith] (jquery.min.js:2)
    at Function.ready (jquery.min.js:2)
    at HTMLDocument.K (jquery.min.js:2)

@fladna9
Copy link

fladna9 commented May 24, 2018

Ok, problem is the qrcode.min.js file.
It works fine on qrcode.js

Tested on Chrome, Safari, Firefox, and had no problem so far. Below is the code of the Testpage i used (just edited index.html with your JS code).

capture d ecran 2018-05-24 a 09 18 49

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ko" lang="ko">
<head>
	<title>Cross-Browser QRCode generator for Javascript</title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no" />
	<script type="text/javascript" src="jquery.min.js"></script>
	<script type="text/javascript" src="qrcode.js"></script>
</head>
<body>
	<div id="qrcode" style="width:100px; height:100px; margin-top:15px;"></div>

	<script type="text/javascript">
		var QRCodeBox = new QRCode(document.getElementById("qrcode"), {
			width: 200,
			height: 200,
			correctLevel: QRCode.CorrectLevel.H
		});
		var str = "ed2k://|file|【电影家园www.idyjy.com下载】寂静之地.HD韩版中英双字.mp4|1129787457|AD3BD4384712D52D2BB09A150AF64D55|h=BMZZS7VBJ4ZAROGOU56245LCBBO6DRO7|/";
		QRCodeBox.makeCode(str);
	</script>
</body>

Will redo a min.js as soon as i have a bit of time for this.
Thanks for the bug submission.

In the mean time, i highly recommend you to use the non-minified version, or to minify it yourself...
I'm not sure i'll have time today to do this. ;-)

Have a good day !

@fladna9
Copy link

fladna9 commented May 24, 2018

I will leave this Open until a fixed qrcode.min.js will be uploaded.

@fladna9 fladna9 added the bug label May 24, 2018
@fladna9 fladna9 self-assigned this May 24, 2018
@suxiaogang
Copy link
Author

nice job dude

@fladna9
Copy link

fladna9 commented May 24, 2018

Fixed in df9405a, closing issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants