Skip to content

Fix unsafe URL launch in LinkToolRenderer#22

Merged
RZEROSTERN merged 1 commit intofeat/phase-2-viewer-completeness-part-2from
copilot/sub-pr-20-again
Mar 25, 2026
Merged

Fix unsafe URL launch in LinkToolRenderer#22
RZEROSTERN merged 1 commit intofeat/phase-2-viewer-completeness-part-2from
copilot/sub-pr-20-again

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 25, 2026

onTap in LinkToolRenderer used Uri.parse directly, risking FormatException on malformed links and allowing non-web schemes (e.g. file://, intent://) to be launched.

Changes

  • link_tool_renderer.dart
    • Uri.parseUri.tryParse; returns early if result is null
    • Scheme guard: rejects anything that isn't http or https
    • Gates launch behind canLaunchUrl; awaits both the check and launchUrl
onTap: block.link.isNotEmpty
    ? () async {
        final uri = Uri.tryParse(block.link);
        if (uri == null) return;
        if (uri.scheme != 'http' && uri.scheme != 'https') return;
        if (await canLaunchUrl(uri)) {
          await launchUrl(uri, mode: LaunchMode.externalApplication);
        }
      }
    : null,

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI mentioned this pull request Mar 25, 2026
21 tasks
Copilot AI changed the title [WIP] [WIP] Address feedback on viewer completeness read-only block types PR Fix unsafe URL launch in LinkToolRenderer Mar 25, 2026
Copilot AI requested a review from RZEROSTERN March 25, 2026 17:43
@RZEROSTERN RZEROSTERN marked this pull request as ready for review March 25, 2026 17:49
@RZEROSTERN RZEROSTERN merged commit f369f9c into feat/phase-2-viewer-completeness-part-2 Mar 25, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants