Skip to content

[FEATURE] Support more url schemes and remove insecure ftp scheme#4537

Draft
DavidGBrett wants to merge 5 commits into
devfrom
url-schemes
Draft

[FEATURE] Support more url schemes and remove insecure ftp scheme#4537
DavidGBrett wants to merge 5 commits into
devfrom
url-schemes

Conversation

@DavidGBrett

@DavidGBrett DavidGBrett commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

closes #4535 - see it for more context

Also closes #4014


Summary by cubic

Expanded URL support to include browser-specific and colon-only schemes, and removed the insecure ftp scheme. Browser bookmarks now always open in a browser tab to ensure consistent handling.

Summary of changes

  • Changed: URL detection now checks both :// and colon-only schemes before auto-adding http/https; keeps strict host checks for http/https and skips host checks for specific schemes (file, chrome*, moz-extension). Browser bookmarks now open via SearchWeb.OpenInBrowserTab to always use a browser.
  • Added: Support for chrome://, edge://, brave://, opera://, vivaldi://, chrome-extension://, moz-extension://, file:///; and colon-only forms like about:, data:, chrome:, chrome-extension:.
  • Removed: ftp:// scheme support in detection and tests.
  • Memory: Negligible; only small static string arrays added.
  • Security: Removing ftp reduces risk. New schemes are handed off to the browser; empty/whitespace-only colon forms are rejected.
  • Tests: Added unit tests for valid and invalid cases of the new schemes; removed ftp cases.

Release Note
You can now open browser-specific and file links (like chrome:// and about:blank) directly from Flow Launcher; ftp links are no longer supported.

Written for commit 19c600c. Summary will update on new commits.

Review in cubic

…brave", "opera", "vivaldi", "edge", "chrome", "chrome-extension", "moz-extension"
… Context.API.OpenUrl

This ensures that it always opens in the browser - instead of letting the system decide which app should handle the URI

This means that non standard schemes like chrome:// will be supported
@github-actions github-actions Bot added this to the 2.2.0 milestone Jun 16, 2026
@DavidGBrett DavidGBrett marked this pull request as ready for review June 16, 2026 13:37
@DavidGBrett DavidGBrett marked this pull request as draft June 16, 2026 13:38
@DavidGBrett DavidGBrett marked this pull request as ready for review June 16, 2026 13:42
@DavidGBrett DavidGBrett marked this pull request as draft June 16, 2026 13:42

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 3 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="Plugins/Flow.Launcher.Plugin.BrowserBookmark/Main.cs">

<violation number="1" location="Plugins/Flow.Launcher.Plugin.BrowserBookmark/Main.cs:107">
P2: Bookmark actions now bypass Flow's configured browser launch settings and always force tab opening.</violation>
</file>

<file name="Plugins/Flow.Launcher.Plugin.Url/Main.cs">

<violation number="1" location="Plugins/Flow.Launcher.Plugin.Url/Main.cs:146">
P1: Colon-scheme validation incorrectly treats `chrome://` as valid because `"//"` passes the non-empty content check.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

if (ColonOnlySchemes.Any(s => scheme.Equals(s, StringComparison.OrdinalIgnoreCase)))
{
var content = input[(colonIndex + 1)..];
return content.Length > 0 && !content.Any(char.IsWhiteSpace);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Colon-scheme validation incorrectly treats chrome:// as valid because "//" passes the non-empty content check.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At Plugins/Flow.Launcher.Plugin.Url/Main.cs, line 146:

<comment>Colon-scheme validation incorrectly treats `chrome://` as valid because `"//"` passes the non-empty content check.</comment>

<file context>
@@ -116,21 +135,37 @@ public bool IsURL(string raw)
+                if (ColonOnlySchemes.Any(s => scheme.Equals(s, StringComparison.OrdinalIgnoreCase)))
+                {
+                    var content = input[(colonIndex + 1)..];
+                    return content.Length > 0 && !content.Any(char.IsWhiteSpace);
+                }
+            }
</file context>
Suggested change
return content.Length > 0 && !content.Any(char.IsWhiteSpace);
if (content.Length == 0 || content.Any(char.IsWhiteSpace))
return false;
if (content.StartsWith("//", StringComparison.Ordinal))
return ChromiumSchemes.Any(s => scheme.Equals(s, StringComparison.OrdinalIgnoreCase)) && content.Length > 2;
return true;

Action = _ =>
{
Context.API.OpenUrl(c.Url);
SearchWeb.OpenInBrowserTab(c.Url);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Bookmark actions now bypass Flow's configured browser launch settings and always force tab opening.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At Plugins/Flow.Launcher.Plugin.BrowserBookmark/Main.cs, line 107:

<comment>Bookmark actions now bypass Flow's configured browser launch settings and always force tab opening.</comment>

<file context>
@@ -104,7 +104,7 @@ public List<Result> Query(Query query)
                         Action = _ =>
                         {
-                            Context.API.OpenUrl(c.Url);
+                            SearchWeb.OpenInBrowserTab(c.Url);
 
                             return true;
</file context>
Suggested change
SearchWeb.OpenInBrowserTab(c.Url);
Context.API.OpenUrl(c.Url);

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The URL plugin's scheme handling is refactored from a single UrlSchemes array into categorized arrays (host-validated, non-host-validated double-slash, colon-only). FTP support is removed. IsURL gains colon-only and non-host-validated double-slash scheme paths. The query action conditionally skips scheme prepending. BrowserBookmark switches bookmark opens to SearchWeb.OpenInBrowserTab. Tests are updated to match.

Changes

URL Plugin Scheme Overhaul and Bookmark Open Change

Layer / File(s) Summary
Scheme classification arrays, query action, and IsURL validation
Plugins/Flow.Launcher.Plugin.Url/Main.cs
Single UrlSchemes list replaced with HostValidatedSchemes, ChromiumSchemes, NonHostValidatedDoubleSlashSchemes, ColonOnlySchemes, and AllDoubleSlashSchemes. Query action skips http/https prepend when input already has a recognized scheme prefix. IsURL adds colon-only scheme validation (non-empty, no whitespace after :) and an early-return for non-host-validated :// schemes. FTP removed from host-validated schemes.
URL plugin test coverage updates
Flow.Launcher.Test/Plugins/UrlPluginTest.cs
Removes ftp://google.com and ftp://110.10.10.10 from valid cases. Adds valid cases for chrome://, edge://, file:///, about:, data:, chrome-extension: schemes. Adds invalid cases for whitespace-containing colon schemes, empty colon schemes (about:, chrome:), and empty chrome://.
BrowserBookmark open method
Plugins/Flow.Launcher.Plugin.BrowserBookmark/Main.cs
Both the search-results and top-results Action delegates now call SearchWeb.OpenInBrowserTab(c.Url) instead of Context.API.OpenUrl(c.Url).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • Flow-Launcher/Flow.Launcher#3944: Modifies the same Plugins/Flow.Launcher.Plugin.Url/Main.cs URL handling, IsURL, and scheme recognition logic.
  • Flow-Launcher/Flow.Launcher#4191: Changes the same Plugins/Flow.Launcher.Plugin.Url/Main.cs and Flow.Launcher.Test/Plugins/UrlPluginTest.cs files with scheme-based IsURL validation and test case additions/removals.

Suggested reviewers

  • jjw24
  • Jack251970
  • VictoriousRaptor
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main changes: removing FTP scheme support and adding support for additional URL schemes.
Description check ✅ Passed The description relates to the changeset, explaining the removal of FTP support, addition of new URL schemes, and updates to the BrowserBookmark plugin.
Linked Issues check ✅ Passed The PR fully addresses both linked issues: it removes FTP scheme support (#4535) and implements support for chrome:// and other browser-specific schemes (#4014, #4535), with BrowserBookmark updates for proper scheme handling.
Out of Scope Changes check ✅ Passed All changes are directly aligned with the linked issues: URL scheme removal/addition in the URL plugin, unit test updates for scheme validation, and BrowserBookmark plugin updates for consistent URL handling.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch url-schemes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Plugins/Flow.Launcher.Plugin.Url/Main.cs`:
- Around line 138-148: In the colon-only schemes validation block within the
Main.cs file, the return statement for validating content after the colon does
not account for double-slash patterns. When checking schemes like `chrome` in
`chrome://settings`, the content extracted is `//settings`, which passes the
current validation (length > 0 and no whitespace). Add an additional check to
exclude content that starts with `//` from this colon-only validation path,
allowing it to fall through to the double-slash validation logic instead. Modify
the return statement to ensure that if content begins with `//`, the method
continues to the next validation path rather than returning true.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0d537a80-e08e-4b89-a2ff-1b7fb232e310

📥 Commits

Reviewing files that changed from the base of the PR and between 7fbcae1 and 19c600c.

📒 Files selected for processing (3)
  • Flow.Launcher.Test/Plugins/UrlPluginTest.cs
  • Plugins/Flow.Launcher.Plugin.BrowserBookmark/Main.cs
  • Plugins/Flow.Launcher.Plugin.Url/Main.cs

Comment on lines +138 to +148
// Check colon-only schemes (e.g. about:blank, chrome:settings)
var colonIndex = input.IndexOf(':');
if (colonIndex > 0)
{
var scheme = input[..colonIndex];
if (ColonOnlySchemes.Any(s => scheme.Equals(s, StringComparison.OrdinalIgnoreCase)))
{
var content = input[(colonIndex + 1)..];
return content.Length > 0 && !content.Any(char.IsWhiteSpace);
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Bug: chrome:// incorrectly accepted as valid via colon-only path.

For Chromium schemes that support both forms (chrome:settings and chrome://settings), this check accepts chrome:// because content "//" passes the length and whitespace validation. The test at line 111 expects chrome:// to be invalid.

When content starts with //, defer to the double-slash validation path instead.

🐛 Proposed fix
         // Check colon-only schemes (e.g. about:blank, chrome:settings)
         var colonIndex = input.IndexOf(':');
         if (colonIndex > 0)
         {
             var scheme = input[..colonIndex];
             if (ColonOnlySchemes.Any(s => scheme.Equals(s, StringComparison.OrdinalIgnoreCase)))
             {
                 var content = input[(colonIndex + 1)..];
+                // Defer double-slash forms to URI-based validation below
+                if (!content.StartsWith("//"))
+                {
                     return content.Length > 0 && !content.Any(char.IsWhiteSpace);
+                }
             }
         }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Check colon-only schemes (e.g. about:blank, chrome:settings)
var colonIndex = input.IndexOf(':');
if (colonIndex > 0)
{
var scheme = input[..colonIndex];
if (ColonOnlySchemes.Any(s => scheme.Equals(s, StringComparison.OrdinalIgnoreCase)))
{
var content = input[(colonIndex + 1)..];
return content.Length > 0 && !content.Any(char.IsWhiteSpace);
}
}
// Check colon-only schemes (e.g. about:blank, chrome:settings)
var colonIndex = input.IndexOf(':');
if (colonIndex > 0)
{
var scheme = input[..colonIndex];
if (ColonOnlySchemes.Any(s => scheme.Equals(s, StringComparison.OrdinalIgnoreCase)))
{
var content = input[(colonIndex + 1)..];
// Defer double-slash forms to URI-based validation below
if (!content.StartsWith("//"))
{
return content.Length > 0 && !content.Any(char.IsWhiteSpace);
}
}
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Plugins/Flow.Launcher.Plugin.Url/Main.cs` around lines 138 - 148, In the
colon-only schemes validation block within the Main.cs file, the return
statement for validating content after the colon does not account for
double-slash patterns. When checking schemes like `chrome` in
`chrome://settings`, the content extracted is `//settings`, which passes the
current validation (length > 0 and no whitespace). Add an additional check to
exclude content that starts with `//` from this colon-only validation path,
allowing it to fall through to the double-slash validation logic instead. Modify
the return statement to ensure that if content begins with `//`, the method
continues to the next validation path rather than returning true.

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.

Remove ftp support and add support for more URL schemes in URL Plugin BUG: chrome:// queries in Web Search and URL plugins have stopped working.

1 participant