Fixed crash within QR generation for larger SSIDs and Passwords

This commit is contained in:
Glenn de Haan
2025-03-13 19:10:15 +01:00
parent 054dfcfdbc
commit 6b1008b52f
3 changed files with 9 additions and 4 deletions

View File

@@ -141,13 +141,18 @@ module.exports = {
.fontSize(10)
.text(`${t('scan')}:`);
doc.image(await qr(), 75, variables.unifiSsidPassword !== '' ? 215 : 205, {
doc.image(await qr(), 75, variables.unifiSsidPassword !== '' ? 255 : 205, {
fit: [75, 75],
align: 'center',
valign: 'center'
});
doc.moveDown(6);
// Check if we need to move the text down extra or not depending on if large SSIDs or Passwords are used
if(variables.unifiSsidPassword !== '' && (variables.unifiSsidPassword.length < 16 || variables.unifiSsidPassword.length < 32)) {
doc.moveDown(2);
}
doc.moveDown(2);
}

View File

@@ -21,7 +21,7 @@ module.exports = (buffer = false) => {
return new Promise((resolve) => {
if(!buffer) {
QRCode.toDataURL(qrText, { version: 4, errorCorrectionLevel: 'Q' }, (err, url) => {
QRCode.toDataURL(qrText, { version: 6, errorCorrectionLevel: 'Q' }, (err, url) => {
if(err) {
log.error(`[Qr] Error while generating code!`);
log.error(err);
@@ -30,7 +30,7 @@ module.exports = (buffer = false) => {
resolve(url);
});
} else {
QRCode.toBuffer(qrText, { version: 4, errorCorrectionLevel: 'Q' }, (err, buffer) => {
QRCode.toBuffer(qrText, { version: 6, errorCorrectionLevel: 'Q' }, (err, buffer) => {
if(err) {
log.error(`[Qr] Error while generating code!`);
log.error(err);

View File

@@ -7,7 +7,7 @@ const variables = require('../modules/variables');
* Util function to calculate paper size based on voucher data
*/
module.exports = (voucher) => {
let base = variables.unifiSsid !== '' ? variables.unifiSsidPassword !== '' ? 385 : 375 : 260;
let base = variables.unifiSsid !== '' ? variables.unifiSsidPassword !== '' ? 415 : 375 : 260;
if(voucher.qos_usage_quota) {
base += 10;