Repository navigation
[Zen Browser] Fix New Tab search on Windows - #32787
Conversation
|
Thank you for your contribution! 🎉 🔔 @Keyruu @theherk @walker-tx @Jimmy-b36 @sdaza @elliothco @ridemountainpig @Davidferl @sjasct @pernielsentikaer @Zheckan @Diwanshumidha @vmrjnvc @MrGHPrice @Caffeine19 you might want to have a look. You can use this guide to learn how to check out the Pull Request locally in order to test it. 📋 Quick checkout commandsBRANCH="zen-browser-windows-search"
FORK_URL="https://github.com/candygoogy/extensions.git"
EXTENSION_NAME="zen-browser"
REPO_NAME="extensions"
git clone -n --depth=1 --filter=tree:0 -b $BRANCH $FORK_URL
cd $REPO_NAME
git sparse-checkout set --no-cone "extensions/$EXTENSION_NAME"
git checkout
cd "extensions/$EXTENSION_NAME"
npm install && npm run devWe're currently experiencing a high volume of incoming requests. As a result, the initial review may take up to 15 business days. |
[Medium impact] The PR appears safe to merge. SummaryFixes Windows searches and history links in Zen Browser.
Reviews (3) · Last reviewed commit: "Update CHANGELOG.md" · Reviewed by Greptile |
0xdhrv
left a comment
There was a problem hiding this comment.
Hey @candygoogy 👋
Thanks for your contribution 🔥 The windowsArg helper follows the Windows command-line quoting rules carefully (escaped quotes, doubled backslashes before a quote and at the end), and the Windows-only test that sends real values through a child process is a really solid way to prove each query arrives as one argument.
Here's everything I found in this pass:
Blocking
No issues found.
Optional (no action needed to merge)
- In
src/components/ZenActions.tsx, the explicit-engine path appends the raw query to the search URL (${searchUrlPrefix}${query}) on both platforms. A query with&,#or+could be cut short or changed by the search engine. Wrapping it inencodeURIComponentwould keep it intact. This predates your PR, so it's fine as a follow-up. - Also in
src/components/ZenActions.tsx, opening a history entry on Windows buildsStart-Process "zen" "${url}". The URL sits in a double-quoted PowerShell string, so$sequences in it can be expanded. Passing it through your newpsLiteral(windowsArg(url))would make it as safe as the search path. This also predates your PR.
Feel free to reach me here or on Slack if anything is unclear.
|
Thanks for the review! I fixed both in this PR: the search query is now URL-encoded, and history entries on Windows go through the same quoting as search. Tested the same way against Zen on Windows; the PR description has the details. |
|
Published to the Raycast Store: |
|
🎉 🎉 🎉 We've rewarded your Raycast account with some credits. You will soon be able to exchange them for some swag. |
Description
Fixes #24362.
On Windows, New Tab starts Zen through PowerShell's
Start-Process, which joins its arguments with spaces and passes them to Zen without quoting them. This breaks both search paths:Start-Process "zen" 'https://google.com/search?q=two words'https://google.com/search?q=twoandwords, so it opens a search for "two" plus a tab forhttp://words/(#24362)Start-Process "zen" "-search" 'two words'Start-Processonly takes two positional arguments, so every search fails with "A positional parameter cannot be found that accepts argument ...", even a single wordChanges in
src/actions/powershell.ts:windowsArghelper quotes each argument for the Windows command line ("...", with"escaped as\"and the backslashes before a quote doubled), and the scripts pass it with-ArgumentList. The whole string is still a single-quoted PowerShell literal, so$(...)in a query is not evaluated.-searchvalue that starts with-or/as an option, even when it's quoted, and nothing opens. Such a query gets a leading space, which search engines ignore.After review, two older issues in
src/components/ZenActions.tsxare fixed too:encodeURIComponent, so&,#and+stay part of the search (before,tom & jerrysearched fortom). This applies on macOS and Windows.Start-Process "zen" "${url}", where PowerShell expands$inside double quotes. It now goes through the same quoting as search (openUrlPowerShellScript, which replacessearchPowerShellScript).The tests in
tests/powershell.test.cjsare updated for the new scripts. A new Windows-only test passeswindowsArgvalues through a real command line to a child process and checks that each one arrives as a single, unchanged argument.Testing
On Windows 11 with Zen 1.23.4b:
npm run buildandnpm run lintpass, andnode --test tests/powershell.test.cjspasses (11/11). With the oldpowershell.ts, 9 of the 11 tests fail.runPowerShellScriptdoes (powershell.exe -Command -with the script on stdin), with a local test search engine set as Zen's default, and logged the queries it received. Before:two wordsarrived astwoplus anhttp://words/tab, and Browser Default failed on every query. After:two words,say "hi" now,dir\sub\ "x",trailing\,it's $(calc) $env:USERNAME,caffè 日本,-foo bar,/r/rustand--helpeach arrive as one search, through both paths, whether Zen is already running or not.tom & jerry,c++ #1anda+b=carrived astom,canda b=c, and a history URL containing$env:USERNAMEand$(Get-Date -Format yyyy)arrived with both expanded (the command ran). With the fix, all of them arrive unchanged.npx tsc --noEmitalso passes.Checklist
npm run buildand tested this distribution build in Raycastassetsfolder are used by the extension itselfREADMEare located outside the metadata folder if they were not generated with our metadata tool