Skip to content

Commit 6f56057

Browse files
authored
Merge pull request #21 from RZEROSTERN/copilot/sub-pr-20
Fix unsafe URL launch in AttachesRenderer
2 parents 01e4835 + e49c87a commit 6f56057

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

lib/src/presentation/blocks/attaches/attaches_renderer.dart

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,15 @@ class AttachesRenderer extends BlockRenderer<AttachesBlock> {
1616

1717
return InkWell(
1818
onTap: block.url.isNotEmpty
19-
? () => launchUrl(Uri.parse(block.url),
20-
mode: LaunchMode.externalApplication)
19+
? () async {
20+
final uri = Uri.tryParse(block.url);
21+
if (uri == null) return;
22+
final scheme = uri.scheme.toLowerCase();
23+
if (scheme != 'http' && scheme != 'https') return;
24+
if (await canLaunchUrl(uri)) {
25+
await launchUrl(uri, mode: LaunchMode.externalApplication);
26+
}
27+
}
2128
: null,
2229
borderRadius: BorderRadius.circular(8),
2330
child: Container(

0 commit comments

Comments
 (0)