From 5e4fcfad0fb6c67e1c72d6391799febf02d9131a Mon Sep 17 00:00:00 2001 From: r-zakarya <82443831+r-zakarya@users.noreply.github.com> Date: Mon, 28 Sep 2026 11:29:12 +0100 Subject: [PATCH] fix(qr): dire "ce QR n'est pas un code 2FA" au lieu de "aucun QR" Un QR de texte, ou un QR dynamique qui encode un lien de suivi, etait lu puis ecarte en silence : l'exe repondait "aucun QR 2FA trouve", l'APK continuait de viser sans rien dire. Le texte d'un autre QR ne part toujours pas a la page ; seul le fait qu'un QR a ete lu est signale. Co-Authored-By: Claude Opus 5.5 --- delphi-backend/UMainForm.pas | 13 ++++++++++--- js/app.js | 8 ++++++-- mainApk.pas | 8 ++++++++ 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/delphi-backend/UMainForm.pas b/delphi-backend/UMainForm.pas index 85cb238..bfedfbd 100644 --- a/delphi-backend/UMainForm.pas +++ b/delphi-backend/UMainForm.pas @@ -1404,9 +1404,14 @@ begin procedure var LText: string; + LFound: Boolean; begin Sleep(400); // laisser Windows retirer la fenetre de l'ecran LText := ScanScreenForQr; + // UN QR LU N'EST PAS UN QR DE 2FA. Le texte d'un autre QR ne part pas a + // la page - il n'a rien a y faire -, mais le FAIT qu'un QR a ete lu, + // si : "aucun QR" alors qu'il y en avait un envoyait chercher ailleurs. + LFound := LText <> ''; if Pos('otpauth://', LowerCase(LText)) <> 1 then LText := ''; TThread.Queue(nil, procedure @@ -1414,12 +1419,14 @@ begin LJs: TJSONString; begin RestoreWindowFromTray; - if LText = '' then LogLine('qr/screen: no otpauth QR found') - else LogLine('qr/screen: otpauth QR found'); + if LText <> '' then LogLine('qr/screen: otpauth QR found') + else if LFound then LogLine('qr/screen: a QR code, but not a 2FA one') + else LogLine('qr/screen: no QR code on screen'); LJs := TJSONString.Create(LText); try WebBrowser.ExecuteJavaScript( - 'if(window.Bridge&&Bridge.onScreenQr)Bridge.onScreenQr(' + LJs.ToJSON + ')'); + 'if(window.Bridge&&Bridge.onScreenQr)Bridge.onScreenQr(' + LJs.ToJSON + + ',' + BoolToStr(LFound, True).ToLower + ')'); finally LJs.Free; end; diff --git a/js/app.js b/js/app.js index ba6d323..7eeeaf5 100644 --- a/js/app.js +++ b/js/app.js @@ -4839,9 +4839,13 @@ function soTotpField(plainSecret) { const scan = el('button', { class: 'icon-btn icon-btn-sm', type: 'button', title: 'Scan the 2FA QR code shown on screen' }); scan.appendChild(icon('i-qr')); scan.addEventListener('click', () => { - Bridge.onScreenQr = (text) => { + Bridge.onScreenQr = (text, found) => { const secret = parseOtpAuthUri(text || ''); - if (!secret) { toast('No 2FA QR code found on screen', 'warning'); return; } + if (!secret) { + toast(found ? 'This QR code is not a 2FA code (it has no otpauth:// link)' + : 'No QR code found on screen', 'warning'); + return; + } input.value = secret; updateTotpDisplay(); soDirtyCheck(); diff --git a/mainApk.pas b/mainApk.pas index bf106e0..b8ee1ae 100644 --- a/mainApk.pas +++ b/mainApk.pas @@ -3898,8 +3898,16 @@ begin StopScan; ApplySyncLink(Trim(Copy(LText, Pos('pmserver://sync?', LText), MaxInt))); end + // UN QR LU, MAIS PAS LE BON. On continue de viser - plusieurs QR + // peuvent etre dans le champ - et le bandeau dit pourquoi rien ne + // se passe, au lieu d'un scan qui semble ne rien voir. + else if FScanTotp then + FScanLbl.Text := 'This QR code is not a 2FA code - aim at the one the site shows' else + begin + FScanLbl.Text := 'This QR code is not the one shown by the PC'; Log('QR scan: not a sync link, first char code ' + IntToStr(Ord(LText[1]))); + end; end); end).Start; end);