Skip to content

Fix argument quoting lost in omarchy-launch-or-focus-webapp - #14757

Open
Caprio-ai wants to merge 5 commits into
omacom:quattrofrom
Caprio-ai:patch-1
Open

Caprio-ai wants to merge 5 commits into
omacom:quattrofrom
Caprio-ai:patch-1

Conversation

@Caprio-ai

@Caprio-ai Caprio-ai commented Oct 9, 2026 •

Copy link
Copy Markdown

omarchy-launch-or-focus-webapp flattens its arguments into a single string before handing them to omarchy-launch-or-focus, which runs that string through eval:

LAUNCH_COMMAND="omarchy-launch-webapp $@"
exec omarchy-launch-or-focus "$WINDOW_PATTERN" "$LAUNCH_COMMAND"

That drops the quoting helpers.lua's shell_quote already applied one level up, so any shell metacharacter in the URL gets re-interpreted by the eval instead of passed through as data.

What breaks today

Any webapp binding with focus = true goes through this wrapper. A URL with a query string gets silently mangled:

URL What omarchy-launch-webapp actually receives
https://example.com/?q=a;b c https://example.com/?q=a
https://app.hey.com/x?display=standalone&new_window=true https://app.hey.com/x?display=standalone
https://example.com/x`id`y https://example.com/xuid=0(root) gid=0(root) groups=0(root)y

That last one isn't just truncation, the backtick actually runs. None of the webapp URLs shipped in applications.lua happen to contain one, so nothing in the default config is affected, but the eval is sitting there waiting for the next URL that does.

Fix

LAUNCH_COMMAND="omarchy-launch-webapp $(printf '%q ' "$@")"

printf '%q ' quotes each argument so the eval reconstructs the exact argv the wrapper received instead of re-splitting it.

Checked against every call shape currently in the tree:

Call Before After
"ChatGPT" "https://chatgpt.com/?model=gpt-5" argc=1, intact same
"App" "https://example.com" "--new-window" "--class=Foo" argc=3, intact same
"X" 'https://example.com/a$(touch MARKER)b' truncated, MARKER created intact, nothing executes
"Y" 'https://example.com/?q=a;b c' truncated intact
"Z" '...x`id`y' backtick runs intact

No existing call shape changes behavior, only the cases that are already broken today.

omarchy-launch-or-focus-tui is intentionally left out

It has the same eval exec $LAUNCH_COMMAND pattern, but there the re-splitting is load-bearing: helpers.lua:121 passes shell_quote(value.tui) as one argument (e.g. zsh -c 'fastfetch; read -k 1'), and omarchy-launch-tui expects it to come back apart as -e "$1" "${@:2}". Quoting it the same way collapses it to a single argument and breaks that path, so I left the TUI wrapper as is.

Update: guard and regression test

  • No-argument guard. printf '%q ' "$@" with an empty "$@" prints '', which would reach omarchy-launch-webapp as one empty argument. With only a window pattern the wrapper now passes nothing. The in-tree caller (helpers.lua) always passes two arguments, so this only matters for direct CLI use.
  • Test: test/shell.d/launch-or-focus-webapp-test.sh runs the real wrapper and the real omarchy-launch-or-focus, stubbing only hyprctl and setsid, and compares the exact argv that comes out. 13 checks: &, ;, spaces, #fragment, ', ", glob characters, flags, $(...), backticks, ;touch, "nothing gets executed", and the no-URL case. It fails on the original script and passes with the fix, also with Replace eval with quote-aware word split in omarchy-launch-or-focus #12406 applied on top.

How this relates to the other PRs

Known limits

  • Control characters (a tab, say) and non-ASCII under a non-UTF-8 locale make printf %q emit $'...', which Replace eval with quote-aware word split in omarchy-launch-or-focus #12406's validator refuses.
  • A trailing space in an argument merges with the next one because of the unquoted $LAUNCH_COMMAND before eval in omarchy-launch-or-focus. That can't be fixed from the wrapper.
  • ./test/cli has one failure ("theme template mix helper works") that is identical on a clean checkout. I didn't run shellcheck or the whole ./test/shell suite.

omarchy-launch-or-focus-webapp flattens "$@" into LAUNCH_COMMAND before it's run through eval in omarchy-launch-or-focus, which drops the quoting helpers.lua already applied. A URL containing a semicolon, ampersand, or backtick gets truncated or re-executed instead of passed through as data. Wrap the arguments with printf '%q ' so the eval reconstructs the original argv.

omarchy-launch-or-focus-tui has the same eval but isn't touched here: helpers.lua passes TUI commands as one pre-joined string that's meant to be re-split, so quoting it would break that path.
@greptile-apps

greptile-apps Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the test move fixes the previous finding.

Summary

The PR quotes forwarded webapp arguments before omarchy-launch-or-focus reads them through eval.

  • Webapp URLs and flags keep their original arguments through launch.

Since the previous review, only the test's location changed. No new issues were found.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A["Window pattern, URL and flags"] --> B["omarchy-launch-or-focus-webapp"]
  B --> C["Quote each forwarded argument with printf %q"]
  C --> D["omarchy-launch-or-focus"]
  D --> E{"Matching window?"}
  E -->|Yes| F["Focus window"]
  E -->|No| G["eval exec setsid"]
  G --> H["omarchy-launch-webapp"]
Loading

Reviews (3) · Last reviewed commit: "Remove the misplaced copy of the webapp ..." · Reviewed by Greptile

@jandrusk

Copy link
Copy Markdown

Nice catch, and the printf '%q ' fix is the right shape for this wrapper. Your table matches what I'd expect: argv comes back intact, and backticks and $() in a URL stay as data.

Heads-up so this doesn't get lost among siblings: #12800 and #9490 quote the same launch-or-focus-tui/-webapp re-parse, and #12406 (dhh) removes the eval in omarchy-launch-or-focus altogether. If #12406 lands, this one-liner may not be needed. If it doesn't, this is the smallest change of the set for the webapp path. It might be worth saying in the description which of those you'd want it to replace.

printf '%q ' with an empty "$@" prints '', which would reach omarchy-launch-webapp as one empty argument. Only quote when there is something to quote.
Runs the real omarchy-launch-or-focus-webapp and omarchy-launch-or-focus with only hyprctl and setsid stubbed, and checks the exact argv that comes out for URLs with &, ;, quotes, globs, $() and backticks, plus the no-URL case.

set -euo pipefail

source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"

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 New tests never run

The new test is under test/shell.d/test/shell.d/, but test/shell only runs tests directly under test/shell.d/. The suite skips every new check. Running the file directly also fails because line 5 sources a missing sibling base-test.sh.

Move the file to test/shell.d/launch-or-focus-webapp-test.sh so discovery and the existing helper both work.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks for looking at it, and for pointing out the siblings. Fair point, I should have said it in the description from the start.

I just pushed two small things. One is a guard so a bare window pattern doesn't turn into an empty argument (printf '%q ' with nothing to quote prints ''). The other is a test in test/shell.d that runs the real wrapper and omarchy-launch-or-focus, with only hyprctl and setsid stubbed, and checks the exact argv for &, ;, quotes, globs, $(), backticks and the no-URL case. It fails on the original and passes with the change, also with the tip of #12406 applied on top.

On #12406: as far as I can tell it keeps eval behind a validator instead of removing it. So I'd call them complementary. Without quoting in the wrapper, a webapp URL with & or ; goes from being silently cut off to "Refusing to launch".

On #9490: it quotes -webapp like this one, but it also quotes -tui, and I think that breaks. helpers.lua passes the whole zsh -c '...' string as a single argument and omarchy-launch-tui splits it again, so after quoting it arrives as one word. I tried it with the same stubs. That's why I left -tui alone here. If you'd rather take the webapp half of #9490 I'm fine closing this one.

The known limits are at the bottom of the description.

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.

The quoting guard and regression coverage look good, and the -tui distinction makes sense. The remaining issue is still present in the revision I can see: the test is at test/shell.d/test/shell.d/launch-or-focus-webapp-test.sh, not test/shell.d/launch-or-focus-webapp-test.sh.

Consequently, test/shell will not discover it, and running it directly still fails to resolve base-test.sh. Please move the file up one directory; no other changes are needed for this comment.

Tip: You can customize Greptile's behavior for this repo with .greptile/rules.md and .greptile/config.json.

@Caprio-ai

Copy link
Copy Markdown
Author

Thanks for looking at it, and for pointing out the siblings. Fair point, I should have said it in the description from the start.

I just pushed two small things. One is a guard so a bare window pattern doesn't turn into an empty argument (printf '%q ' with nothing to quote prints ''). The other is a test in test/shell.d that runs the real wrapper and omarchy-launch-or-focus, with only hyprctl and setsid stubbed, and checks the exact argv for &, ;, quotes, globs, $(), backticks and the no-URL case. It fails on the original and passes with the change, also with the tip of #12406 applied on top.

On #12406: as far as I can tell it keeps eval behind a validator instead of removing it. So I'd call them complementary. Without quoting in the wrapper, a webapp URL with & or ; goes from being silently cut off to "Refusing to launch".

On #9490: it quotes -webapp like this one, but it also quotes -tui, and I think that breaks. helpers.lua passes the whole zsh -c '...' string as a single argument and omarchy-launch-tui splits it again, so after quoting it arrives as one word. I tried it with the same stubs. That's why I left -tui alone here. If you'd rather take the webapp half of #9490 I'm fine closing this one.

The known limits are at the bottom of the description.

The first copy ended up in test/shell.d/test/shell.d/, which test/shell does not scan and where base-test.sh can't be sourced. The copy in the wrong folder is removed in the next commit.
It was created under test/shell.d/test/shell.d/ by mistake. The test now lives in test/shell.d/.
@omarchybot

Copy link
Copy Markdown
Collaborator

Looked at c7d3813 by Claude Opus 5.5 alone. The second opinion (Codex Medium) did not run, because the reviewer's daily budget was already spent when this came up. So the change has not been classified by two models yet, and it has not been run on a worker or labelled. That happens on its next pass, with the second opinion.

What reading it found so far:

Which of these three lands is the maintainer's call. Next, this waits on a classification both models agree on.

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.

3 participants