mirror of
https://github.com/chatmail/core.git
synced 2026-05-02 04:46:29 +03:00
fix: accept QR codes with 'broken' JSON (#6528)
this converts old QR codes to the new format, in an hacky, but simple way, see #6518 for more details and for code snippet then QR code change is esp. bad as ppl will have different versions for some days at least, weakening overall UX, esp. of first-time-users that may come to delta because of praised, seamless multidevice ... :) i tested in https://github.com/deltachat/deltachat-ios/pull/2595 that this actually fixes the problem, and there is no deeper issue with changed chashes or so - seemed not to be the case, at least, with this hack, core accepts QR codes from the released 1.52-and-before series this hack gives user time to update, it can be removed after some months (we can also remove the old BACKUP qr code alltogether then) we should still not wait too long with the PR as there are already versions out with the "new/bad" QR code (and growing, as new iOS installations will get the new format, one cannot revert a version, only pause rollout) --------- Co-authored-by: link2xt <link2xt@testrun.org>
This commit is contained in:
10
src/qr.rs
10
src/qr.rs
@@ -261,6 +261,13 @@ pub enum Qr {
|
||||
},
|
||||
}
|
||||
|
||||
// hack around the changed JSON accidentally used by an iroh upgrade, see #6518 for more details and for code snippet.
|
||||
// this hack is mainly needed to give ppl time to upgrade and can be removed after some months (added 2025-02)
|
||||
fn fix_add_second_device_qr(qr: &str) -> String {
|
||||
qr.replacen(r#","info":{"relay_url":"#, r#","relay_url":"#, 1)
|
||||
.replacen(r#""]}}"#, r#""]}"#, 1)
|
||||
}
|
||||
|
||||
fn starts_with_ignore_case(string: &str, pattern: &str) -> bool {
|
||||
string.to_lowercase().starts_with(&pattern.to_lowercase())
|
||||
}
|
||||
@@ -290,7 +297,8 @@ pub async fn check_qr(context: &Context, qr: &str) -> Result<Qr> {
|
||||
} else if qr.starts_with(SHADOWSOCKS_SCHEME) {
|
||||
decode_shadowsocks_proxy(qr)?
|
||||
} else if starts_with_ignore_case(qr, DCBACKUP2_SCHEME) {
|
||||
decode_backup2(qr)?
|
||||
let qr_fixed = fix_add_second_device_qr(qr);
|
||||
decode_backup2(&qr_fixed)?
|
||||
} else if qr.starts_with(MAILTO_SCHEME) {
|
||||
decode_mailto(context, qr).await?
|
||||
} else if qr.starts_with(SMTP_SCHEME) {
|
||||
|
||||
Reference in New Issue
Block a user