From 83814e5842551bb9569ea92eb90962d15a936b53 Mon Sep 17 00:00:00 2001 From: rustdesk Date: Sun, 19 Mar 2023 16:33:33 +0800 Subject: [PATCH] to suppport old qr code, https://www.reddit.com/r/rustdesk/comments/11utfpf/qr_code/ --- flutter/lib/common.dart | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/flutter/lib/common.dart b/flutter/lib/common.dart index c8cf4680a..c08f5abdc 100644 --- a/flutter/lib/common.dart +++ b/flutter/lib/common.dart @@ -1817,10 +1817,14 @@ class ServerConfig { /// also see [encode] /// throw when decoding failure ServerConfig.decode(String msg) { - final input = msg.split('').reversed.join(''); - final bytes = base64Decode(base64.normalize(input)); - final json = jsonDecode(utf8.decode(bytes)); - + var json = {}; + try { + json = jsonDecode(msg); + } catch (err) { + final input = msg.split('').reversed.join(''); + final bytes = base64Decode(base64.normalize(input)); + json = jsonDecode(utf8.decode(bytes)); + } idServer = json['host'] ?? ''; relayServer = json['relay'] ?? ''; apiServer = json['api'] ?? '';