From 9e4a5985b5fd1377f7c4c1fa9127a00b8fc9abff Mon Sep 17 00:00:00 2001 From: eason <85663565+mango766@users.noreply.github.com> Date: Thu, 19 Mar 2026 00:39:17 +0800 Subject: [PATCH] fix: prevent text starting with URL from being misidentified as link (#2975) Dart's Uri.tryParse is very permissive and will successfully parse strings like "https://example.com some extra text" as valid absolute URIs. This caused the receiver to incorrectly classify any message beginning with a URL as a link, even when it contained additional non-URL text. Add a whitespace check before URI parsing so that only messages consisting entirely of a single URL (with optional surrounding whitespace) are treated as links. Fixes #2904 Co-authored-by: easonysliu --- app/lib/pages/receive_page.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/lib/pages/receive_page.dart b/app/lib/pages/receive_page.dart index afe291ed..a3a3bf62 100644 --- a/app/lib/pages/receive_page.dart +++ b/app/lib/pages/receive_page.dart @@ -46,7 +46,7 @@ class ReceivePageVm { required this.onAccept, required this.onDecline, required this.onClose, - }) : isLink = message != null && (Uri.tryParse(message)?.isAbsolute ?? false); + }) : isLink = message != null && !message.trim().contains(RegExp(r'\s')) && (Uri.tryParse(message.trim())?.isAbsolute ?? false); } class ReceivePage extends StatefulWidget {