From ac697888ac115b3b2e3136e7c30c4ef5cad88107 Mon Sep 17 00:00:00 2001 From: "mr. brown" <164935737+fviolence@users.noreply.github.com> Date: Mon, 16 Mar 2026 12:13:08 +0100 Subject: [PATCH] luci: handle oversized peer config QR generation gracefully (#118) Catch QR rendering failures when exporting peer configurations and show a user-facing message instead of failing silently (for example when large I1-I5 values present). --- .../resources/protocol/amneziawg.js | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/luci-proto-amneziawg/htdocs/luci-static/resources/protocol/amneziawg.js b/luci-proto-amneziawg/htdocs/luci-static/resources/protocol/amneziawg.js index 536cbf7..109d701 100644 --- a/luci-proto-amneziawg/htdocs/luci-static/resources/protocol/amneziawg.js +++ b/luci-proto-amneziawg/htdocs/luci-static/resources/protocol/amneziawg.js @@ -72,9 +72,25 @@ function buildSVGQRCode(data, code) { whiteColor: 'white', blackColor: 'black' }; - const svg = uqr.renderSVG(data, options); - code.style.opacity = ''; - dom.content(code, Object.assign(E(svg), { style: 'width:100%;height:auto' })); + + try { + const svg = uqr.renderSVG(data, options); + code.style.opacity = ''; + dom.content(code, Object.assign(E(svg), { + style: 'width:100%;height:auto' + })); + } + catch (e) { + console.warn('QR generation failed:', e); + + code.style.opacity = ''; + dom.content(code, E('div', { + 'class': 'alert-message warning', + 'style': 'margin:0;text-align:center' + }, [ + _('QR code generation failed. The configuration may be too large.') + ])); + } } var cbiKeyPairGenerate = form.DummyValue.extend({