Skip to content

Escape RetroArch desktop entry values - #16345

Open
hizawye wants to merge 3 commits into
omacom:quattrofrom
hizawye:hardening/retro-desktop-values
Open

hizawye wants to merge 3 commits into
omacom:quattrofrom
hizawye:hardening/retro-desktop-values

Conversation

@hizawye

@hizawye hizawye commented Oct 22, 2026 •

Copy link
Copy Markdown

Summary

  • encode desktop string values before writing the launcher
  • quote and escape the core and game paths according to the Desktop Entry Exec rules
  • cover newline, quote, percent, and literal-backslash paths end to end

Why

A ROM filename can contain a newline and create additional keys in the generated desktop file. Quotes, percent field codes, and backslashes also have defined parsing behavior in Desktop Entry Exec values. Applying the string and Exec escaping layers in specification order prevents invalid entries while preserving unusual filenames.

Test

bash test/shell.d/games-retro-install-test.sh

The regression verifies that only one Exec key is written, launches the entry through real gio launch, captures NUL-delimited RetroArch arguments, and confirms that both original paths arrive as distinct, byte-for-byte unchanged arguments.

@greptile-apps

greptile-apps Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

Escapes desktop entry values and quotes RetroArch paths before writing the launcher.

  • RetroArch launchers keep unusual game and core paths intact.

Reviews (3) · Last reviewed commit: "Put two backslashes in the retro test's ..." · Reviewed by Greptile

@omarchybot omarchybot added bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review labels Oct 22, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at b9d6b07 and reproduced on a disposable Omarchy VM. Nothing wrong found and nothing pushed.

The bug is real, and more common than the newline case suggests. I generated launchers for seven ROM names with quattro's script and with this branch, then launched each with gtk-launch, the way the app launcher does. On quattro, Kirby's 100% Adventure.sfc starts RetroArch on Kirby's 100Adventure.sfc (GLib reads % as a field code and drops it). The "Lost" Levels.sfc loses its quotes, a backslash is dropped, and a newline in the name splits Exec= into several keys, so the launcher does not open at all. On this branch all seven reach RetroArch with the exact path, and desktop-file-validate accepts every file. The new test passes here and fails once quattro's script is restored.

Suite: ./test/all on the same VM: 7247 checks pass. Nine test files failed identically on quattro (they were already failing on this VM). Three passed when run alone. lock-appear-budget missed its timing budget by 129 ms; this change touches nothing the shell loads, so I read that as VM timing noise.

Second opinion: Codex at medium effort and muse-spark-1.3 at high reviewed it. Both found the escaping correct: string escapes are applied after Exec quoting, as the Desktop Entry spec orders them, and nothing is escaped twice. Their agreement with my reading is not guaranteed to be independent. Codex added one point, which I checked against the source: Quickshell 0.3.2 does not unescape Name= values, so a ROM with a backslash in its name would show \\ in the app list. The launcher is the one at fault there, and omarchy-webapp-install already writes names the same way, so it is not a reason to change this pull request.

The helpers here are the same pair omarchy-webapp-install defines, written with parameter expansion. Whether to share them is the maintainer's call. This now waits on the maintainer.

@chessing234 chessing234 left a comment

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.

desktop_exec_arg already escapes backslashes, then desktop_string_escape escapes them again. a core path a\b is written as a\\b, so the launcher opens a\b. escape the desktop string first, or do not run the backslash pass over Exec.

@hizawye

hizawye commented Oct 23, 2026

Copy link
Copy Markdown
Author

Thanks for flagging this. I reproduced the exact literal-backslash case through the generated desktop file and real gio launch path. The two escaping passes correspond to two parsing layers: Desktop Entry string unescaping, then quoted Exec argument parsing. The launched NUL-delimited argv contains the original single backslash byte-for-byte. Commit 49a4baf adds that case permanently to the existing end-to-end test; it passes while comparing the captured core and game paths exactly. No production escaping change is needed. Please re-check the new regression when convenient.

@omarchybot omarchybot removed the verified Omarchy Triage has verified that this issue is ready for final review label Oct 23, 2026
A backslash before an ordinary letter survives a quoted Exec argument whether or not it was escaped, so the test passed with desktop_exec_arg's backslash pass removed. Two consecutive backslashes fail in both directions, too little escaping or too much.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
Co-Authored-By: muse-spark-1.3-contributor High <noreply@meta.com>
@omarchybot omarchybot added verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Oct 23, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Re-reviewed at 49a4baf on a disposable Omarchy VM, and pushed one small fix to the new test.

The script is right, and the double-escape review does not hold. @chessing234's review says a core path a\b is written as a\\\\b and launched as a\\b. The first half is correct, but the launcher strips two layers. It first unescapes the Desktop Entry string (\\\\ becomes \\), then reads the quoted Exec argument (\\ becomes \), so RetroArch gets a\b. The spec asks for four backslashes for one literal backslash inside a quoted argument. On the VM, a launcher for a\b_libretro.so passed desktop-file-validate, and gio launch handed RetroArch exactly a\b. Escaping the string first would break the newline case instead.

What I pushed (d260c76): the backslash added in 49a4baf sits before a w. A backslash before an ordinary letter survives a quoted Exec argument whether it was escaped or not, so the test still passed with desktop_exec_arg's backslash line deleted. The core path now has two backslashes in a row. On the VM, the test passes on this branch. It fails with that backslash line removed, with it doubled, and with quattro's original script.

Suite: ./test/all at d260c76: 7263 checks pass. Eight test files fail the same way on quattro. i18n-startup and lock-appear-budget failed in the full run but passed when run alone, and this change touches nothing the shell loads.

Second opinion: Codex at medium effort and muse-spark-1.3 at high reviewed both rounds. Both found the gap in the test before I did, and both agree the script's escaping order is correct; that agreement is not guaranteed to be independent. On the fixed test, both found nothing open.

This now waits on the maintainer.

@omarchybot omarchybot removed ready Good to merge verified Omarchy Triage has verified that this issue is ready for final review labels Nov 24, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Codex at high effort re-reviewed d260c76 with Opus 5.5 at high effort and muse-wonder via pi at high thinking. Both reviewers agree that #19965 already brought this production fix to quattro; their agreement is not guaranteed to be independent.

On a disposable Omarchy VM, a gio launch probe preserved the exact RetroArch arguments for percent, quote, backslash and newline filenames with both this branch and current quattro. The original base failed those cases. The regression test also passes against both implementations. What remains here is additional coverage: a real launcher round trip, literal backslashes and newline injection, beyond the file-content checks now in webapp-name-test.sh.

Opus identified one adjustment needed if that test is kept against current quattro: its expected paths need to account for realpath. I confirmed that a symlinked TMPDIR makes the assertion fail even though the launcher passes the correctly resolved paths. Any conflict resolution also needs to preserve quattro's path canonicalization and fallback names.

The old failed translation run no longer has retrievable logs or jobs, so its cause remains unknown. On the VM, the structural test stops at the same locale-generation permission error on this head and its original merge base; extraction passes on both. This does not establish what failed on GitHub, and no full suite pass is claimed.

Nothing pushed. This waits on the maintainer's decision about retaining the additional test now that the production fix has landed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants