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

code length overflow #37

Closed
needbill opened this issue Aug 21, 2019 · 1 comment
Closed

code length overflow #37

needbill opened this issue Aug 21, 2019 · 1 comment

Comments

@needbill
Copy link

Hello,
Based on the example taken on php-qrcode/examples/image.php
If i take the exact same example you wrote : working.
If i just remove the content form moduleValues and put an eccLevel to ECC_H : working.
But i get a code length overflow with the following string of data :
$data = 'otpauth://totp/flupflup.com:marco?secret=II6SXEVSTAQV4SNJ&issuer=flupflup.com';
$options = new QROptions([
'version' => 7,
'outputType' => QRCode::OUTPUT_IMAGE_PNG,
'eccLevel' => QRCode::ECC_H,
'scale' => 5,
'imageBase64' => false,
'moduleValues' => [],
]);
header('Content-type: image/png');
echo (new QRCode($options))->render($data);

It looks like it happen only with ECC_H and the other are working well.
I don't really know if my error is relevant or if I did something wrong. But it might be useful to share.
Here the stacktrace :
Stack trace:

#0 /public_html/vendor/chillerlan/php-qrcode/src/Data/QRDataAbstract.php(118): chillerlan\QRCode\Data\QRDataAbstract->writeBitBuffer('otpauth://totp/...')
#1 /public_html/vendor/chillerlan/php-qrcode/src/Data/QRDataAbstract.php(95): chillerlan\QRCode\Data\QRDataAbstract->setData('otpauth://totp/...')
#2 /public_html/vendor/chillerlan/php-qrcode/src/QRCode.php(205): chillerlan\QRCode\Data\QRDataAbstract->__construct(Object(chillerlan\QRCode\QROptions), 'otpauth://totp/...')
#3 /public_html/vendor/chillerlan/php-qrcode/src/QRCode.php(157): chillerlan\QRCode\QRCode->initDataInterface('otpauth://totp/...')
#4 /public_html/vendor/chillerlan/php-qrcode/src/QRCode.php(230): chillerlan\QRCode\QRCode->getMatrix('otpauth://totp/...')
#5 /public_html/vendor/chillerlan/php-qrcode/src/Data/QRDataAbstract.php on line 230

Anyway, thank's for the tools, you've made a neat job.

@needbill
Copy link
Author

Resolved by putting QRCode::VERSION_AUTO based on the previous issue found. sorry.

SteveRyan-ASU added a commit to asuengineering/UDS-WordPress-FURI that referenced this issue Oct 17, 2022
Prevents fatal PHP error that can occur when the string to convert to the QR code exceeds the preset max-bits setting. (Previously hard coded to level 10.)

chillerlan/php-qrcode#37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant