Repository navigation
Conversation
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.
|
|
Nice catch, and the Heads-up so this doesn't get lost among siblings: #12800 and #9490 quote the same |
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" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
|
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 ( On #12406: as far as I can tell it keeps On #9490: it quotes 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/.
|
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. |
omarchy-launch-or-focus-webappflattens its arguments into a single string before handing them toomarchy-launch-or-focus, which runs that string througheval:That drops the quoting
helpers.lua'sshell_quotealready applied one level up, so any shell metacharacter in the URL gets re-interpreted by theevalinstead of passed through as data.What breaks today
Any webapp binding with
focus = truegoes through this wrapper. A URL with a query string gets silently mangled:omarchy-launch-webappactually receiveshttps://example.com/?q=a;b chttps://example.com/?q=ahttps://app.hey.com/x?display=standalone&new_window=truehttps://app.hey.com/x?display=standalonehttps://example.com/x`id`yhttps://example.com/xuid=0(root) gid=0(root) groups=0(root)yThat last one isn't just truncation, the backtick actually runs. None of the webapp URLs shipped in
applications.luahappen to contain one, so nothing in the default config is affected, but theevalis sitting there waiting for the next URL that does.Fix
LAUNCH_COMMAND="omarchy-launch-webapp $(printf '%q ' "$@")"printf '%q 'quotes each argument so theevalreconstructs the exactargvthe wrapper received instead of re-splitting it.Checked against every call shape currently in the tree:
"ChatGPT" "https://chatgpt.com/?model=gpt-5""App" "https://example.com" "--new-window" "--class=Foo""X" 'https://example.com/a$(touch MARKER)b'MARKERcreated"Y" 'https://example.com/?q=a;b c'"Z" '...x`id`y'No existing call shape changes behavior, only the cases that are already broken today.
omarchy-launch-or-focus-tuiis intentionally left outIt has the same
eval exec $LAUNCH_COMMANDpattern, but there the re-splitting is load-bearing:helpers.lua:121passesshell_quote(value.tui)as one argument (e.g.zsh -c 'fastfetch; read -k 1'), andomarchy-launch-tuiexpects 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
printf '%q ' "$@"with an empty"$@"prints'', which would reachomarchy-launch-webappas 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/shell.d/launch-or-focus-webapp-test.shruns the real wrapper and the realomarchy-launch-or-focus, stubbing onlyhyprctlandsetsid, 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
evalbehind a validator, so it complements this. Without quoting in the wrapper, a webapp URL with∨goes from silently truncated to a hard "Refusing to launch". Checked against its tip (73e0dd0).-webapptoo, but alsoomarchy-launch-or-focus-tui. That breaks the TUI path:helpers.luapassesvalue.tui(e.g.zsh -c 'fastfetch; read -k 1') as one argument thatomarchy-launch-tuire-splits with-e "$1" "${@:2}". With the same stubs it arrives today as-e zsh -c 'fastfetch; read -k 1', and with Quote omarchy-launch-or-focus-tui and -webapp arguments like install-app #9490's-tuias-e 'zsh -c ...'in one word (and the derived app-id gets cut toorg.omarchy.).Known limits
printf %qemit$'...', which Replace eval with quote-aware word split in omarchy-launch-or-focus #12406's validator refuses.$LAUNCH_COMMANDbeforeevalinomarchy-launch-or-focus. That can't be fixed from the wrapper../test/clihas one failure ("theme template mix helper works") that is identical on a clean checkout. I didn't run shellcheck or the whole./test/shellsuite.