Implements Global URL Scheme Overrides - #13544
Conversation
Introduces the CMake option for an optional global URL scheme override feature, following the existing KPXC_FEATURE_BROWSER/SSHAGENT/FDOSECRETS pattern: option declaration, KPXC_MINIMAL opt-out, feature summary, and the config-keepassx.h define. No consumer yet.
New optional static library (src/urloverride, built only when
KPXC_FEATURE_URLOVERRIDE is on) that maps a URL scheme (e.g. "ssh",
"kdbx") to an external "cmd://" command template, plus a settings page
to manage the rule table (enable, scheme, command, reordering, with a
confirmation prompt before saving changes).
- UrlOverride::getRules/setRules persist the rule list as an XML string
under a single new Config key (UrlOverride_Rules), the same way
KeeShare stores its structured settings - no other change to
core/Config, and no second QSettings instance on the config file.
- UrlOverride::findCommand does a literal, case-insensitive match of a
rule's scheme against the URL's own scheme (not a regex), first
enabled match with a non-empty command wins.
- A disabled example rule ("ssh" -> "cmd://ssh {USERNAME}@{URL:HOST}")
is seeded once, on first-ever use, purely for discoverability.
- UrlOverride::executeCommand launches the resolved command; on
Windows it detects console-subsystem targets (e.g. ssh.exe) via the
PE header and forces a new console so they get a visible window,
without doing so for GUI targets like a browser.
DatabaseWidget::openUrlForEntry() now checks UrlOverride::findCommand() for the entry's URL scheme before falling back to the existing cmd://, kdbx:// and default-browser handling, and the existing cmd:// launch path now goes through UrlOverride::executeCommand() to pick up the Windows console-visibility fix. Both are guarded by KPXC_FEATURE_URLOVERRIDE with an unchanged fallback when the feature is built out. MainWindow registers the new "URL Overrides" settings page alongside the existing Shortcuts page.
New guiless testurloverride target (built only when KPXC_FEATURE_URLOVERRIDE is on, like testbrowser/testsshagent), covering: - rule list round-trip through Config, including order, disabled entries, and overwriting with a shorter/empty list - the one-time disabled example rule seeded on first use - scheme normalization (not a regex: "ff://" stores as "ff") - literal case-insensitive scheme matching, first-match-wins ordering, empty scheme/command being skipped rather than blocking lower rules, and URLs with no scheme never matching - XML special characters in a command surviving the save/load round-trip
|
This should not be gated behind a build flag. It should be directly incorporated into the application settings. Was this generated by AI (I assume so given the writeup and headless development). Did you test this yourself (as a human)? Why no screenshots? |
|
Thank you |
…-form input Extracts the URI scheme grammar (ALPHA *(ALPHA / DIGIT / "+" / "-" / ".") per RFC 3986) from a string instead of guessing which surrounding characters to strip. Handles messy input (stray leading characters, doubled-up separators, trailing garbage that isn't ":"/"/") that a naive trim-based approach would get wrong.
UrlOverride::normalizeScheme() duplicated logic that belongs in UrlTools, a general-purpose URL utility namespace used elsewhere in the app. Drop the plugin's own copy and call UrlTools::normalizeScheme() instead; the plugin's own tests now only cover that setRules() applies it before persisting, the extraction grammar itself is covered by TestUrlTools.
|
Linux: no automatic terminal handling Unlike Windows, we intentionally do not attempt to detect or wrap console-subsystem targets on Linux. ELF binaries have no PE-style subsystem flag, and there's no OS-level "hidden console" to reveal — If a rule needs an interactive terminal on Linux, the recommended workaround is to specify a terminal emulator explicitly in the command, e.g.: We're deliberately not auto-detecting a terminal emulator for now (no single portable way to do this across distros/DEs). Once |
isConsoleSubsystemExecutable() was checked against the PATH-resolved program, but QProcess was then started with the original, unresolved name, so the console-subsystem check and the launched binary could diverge.
Add bounds checks that reject malformed or truncated executables before trusting offsets/sizes taken from the file itself: e_lfanew is validated against the file size before seeking to it, and SizeOfOptionalHeader is checked against both the declared and the actual IMAGE_OPTIONAL_HEADER32/64 size before reading it. Prevents misreading Subsystem out of a corrupt or truncated PE.
Add a link to the Entry Placeholders documentation section instead of listing placeholder examples inline.



Implements Global URL Scheme Overrides, similar to KeePass 2.x's "URL Overrides" feature (see #10887). Adds a new Settings page where users can map a URL scheme (e.g.
ssh,kdbx,ftp) to an externalcmd://command template. When an entry's URL matches an enabled rule's scheme, KeePassXC runs that command (with the existing confirmation dialog) instead of opening the URL in the browser.Implementation notes
src/urloverride/(static libraryurloverride), gated by a newKPXC_FEATURE_URLOVERRIDECMake option (defaultON, disabled underKPXC_MINIMAL) — same pattern asKPXC_FEATURE_BROWSER/SSHAGENT/FDOSECRETS.DatabaseWidget::openUrlForEntry()checks the configured rules for the entry's URL scheme before falling back to the existingcmd:///kdbx:///default-browser handling. A new "URL Overrides" page is registered in the Settings dialog.QUrl::scheme()) — not a regular expression — sosshnever accidentally matchessshfs. The first enabled rule with a non-empty command wins; a rule with an empty command is skipped rather than blocking a lower-priority rule for the same scheme.ssh→cmd://ssh {USERNAME}@{URL:HOST}) is seeded once on first use, so the feature and its placeholder syntax are discoverable in the settings page without doing anything until a user explicitly enables it.cmd://command now detects console-subsystem targets (e.g.ssh.exe) via their PE header and forces a new console for them specifically, so they get a visible window and can prompt for passwords/host-key confirmations interactively — while GUI targets (e.g. a browser) are left unaffected.Screenshots
Not included — built and tested in a headless CI-style environment, no screen capture available for this session. UI surface added is a single new "URL Overrides" page under Settings: a 3-column table (Enabled / URL Scheme / Command) with Add / Remove / Move Up / Move Down buttons and an explanatory label.
Testing strategy
testurloverrideunit test target (guiless, built only whenKPXC_FEATURE_URLOVERRIDEis on, same astestbrowser/testsshagent), covering:ff:///ff:/ffall normalize toff— confirming it's not treated as a regex)&,<,>,",') in a command surviving a save/load round-tripsshpointing atC:\Windows\System32\OpenSSH\ssh.exe, confirming the execute-command dialog appears, and confirming a real visible console window opens (verified the Windows console-allocation behavior specifically, since that requires real process/console state and isn't meaningfully unit-testable).ShortcutSettingsPage,BrowserSettingsPage), none of which have dedicated GUI tests either.