Repository navigation
Conversation
explorer.exe parses its own command line: an `=` anywhere in a URL (any query string) made it open the Documents folder, a `,` cut the URL there, and it kept only the first 259 characters. Links now go to ShellExecuteExW through the `open` crate (already in Cargo.lock), Windows only.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
A browser never sends the fragment, so the page served for the first request asks for /fragment/<fragment> and the test checks that request.
|
@coderabbitai Thanks for the review. On the inconclusive linked-issue check:
|
|
Tip For best results, initiate chat on the files or code changes. Analysis chain
This addresses my linked-issue verification concern. A synthetic regression test is appropriate here; no private sharing URL is needed. I verified the test code, but I did not run the Windows browser test. Your reported Windows 11 result supplies the runtime evidence. The original OneDrive report remains unconfirmed, but that does not invalidate this focused launcher fix. If you found this review helpful, would you consider giving us a shout-out on X? Thank you for using CodeRabbit! You are interacting with an AI system. |
Fixes #2085
Cause
On Windows,
open_with_system(apps/gridcraft/src/main.rs) opened links by spawningexplorer <url>. explorer.exe parses its own command line, and it doesn't treat a URL as one opaque argument. I measured this on Windows 11 by sending URLs through the same call to a local server that logs each request:explorerhttp://127.0.0.1:8765/h1/h1…/q2?x/q2?x…/q1?x=1,…/q3/a=b,…/t1?x=1&y=2…/q6/a,b/q6/a(cut at the comma)"…/L1?redeem=<2100 chars>&ithint=folder"(quoted)So any link with a query string (
?id=1) opened the user's Documents folder. That is the reporter's "Hyperlink opens my I:\onedrive\documents instead of the web address". A long share link that does reach the browser loses its query past 259 characters, which matches the earlier report of landing on the OneDrive root instead of the subfolder. Quoting the argument fixes=and,but not the length cut, so explorer.exe can't be made to work for URLs.Fix
On Windows, links go to the shell with
ShellExecuteExW, which passes the URL whole to the registered browser or mail handler. Python'sos.startfileuses the same call, and with it the same URLs arrived intact in the experiment above. The workspace forbidsunsafe, so the call goes through theopencrate (open::that_detachedwith itsshellexecute-on-windowsfeature). That crate is already inCargo.lockat 5.4.4 (throughegui_kittest), and so is its one extra dependency for this feature,dunce. It is added as a Windows-only dependency, pinned exactly, like the macOSobjc2crates. The lockfile change is two dependency-list lines.The link policy is unchanged:
classifystill lets onlyhttp,httpsandmailtothrough. macOS (open) and Linux/BSD (xdg-open) are unchanged: the platform-specific part moved into alaunchfunction with acfg(windows)and acfg(not(windows))body.Tests
open_with_system_tests::a_long_address_with_a_query_reaches_the_browser_whole(Windows only) binds a local listener, callsopen_with_systemwithhttp://127.0.0.1:<port>/:f:/g/personal/a1/EaB?resid=A1%21123&ithint=folder,oneup&redeem=<2048 × x>#Sheet2-B7, and asserts that the first request the browser makes there has exactly that path and query. A browser never sends the fragment, so the page served for that request asks for/fragment/<fragment>, and the test asserts that this second request is/fragment/Sheet2-B7. It is#[ignore]because it starts the machine's default browser, which CI shouldn't do. Run it withcargo test -p gridcraft --bin gridcraft -- --ignored a_long_address.launchtemporarily put back toCommand::new("explorer").arg(target), the test fails after 30 s withleft: None(no request ever arrived), and an Explorer window showing Documents was left open. With the fix it passes.cargo test -p gridcraft --bin gridcraft -- --include-ignored: 35 passed.cargo clippy --all-targets -p gridcraft -- -D warningsandcargo fmt -p gridcraft --checkare clean (Windows 11).Not changed
open_with_system. They will conflict with this change textually but not in intent. links: spawn the Windows opener by absolute path (#2176) #2204 still hands URLs to explorer.exe, so=in a query and the 259-character cut would remain with it alone. Local file and folder links open; =HYPERLINK() cells follow their link (#2596) #2601's local paths could go through the samelaunch;ShellExecuteExWopens files and folders too.read_hyperlinks(crates/xlsx/src/sheet_read/parts.rs) takes the relationship target as written and appendslocationas#fragment.crates/xlsx/src/tests/fixtures.rsassertshttps://example.com/a?b=1&c=2after import.open) and Linux/BSD (xdg-open) receive the URL as one argument with no shell parsing. They are not changed here, and the test covers Windows only.=HYPERLINK()cells do nothing when clicked is separate (Local file and folder links open; =HYPERLINK() cells follow their link (#2596) #2601 covers it).craft-update'sopen()in storytold/craft-libs (crates/update/src/process.rs) uses explorer.exe the same way. That is another repository and is not touched here.Summary by CodeRabbit