mirror of
https://github.com/localsend/localsend.git
synced 2026-06-23 04:10:07 +00:00
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 <easonysliu@tencent.com>
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user