Repository navigation
fix(desktop): skip only ASCII whitespace before a desktop entry key - #13126
Merged
N0zoM1z0 merged 1 commit intoNov 21, 2026
Merged
Conversation
The key reader stripped each line with JavaScript's trimStart(), which also removes Unicode spaces such as U+00A0 and U+3000. GLib skips only g_ascii_isspace, so it keeps those bytes inside the key and the record never matches Name= or Hidden=. The drift had a safety direction: a line indented with U+00A0 and reading Hidden=true was accepted as a hidden override by REA but never by the desktop environment, so findHiddenDesktopEntry() claimed a deletion that GLib would not honour. morluto#12708 closed this for group headers by validating the captured padding against GLib's ASCII set; the blank-line, comment and key checks still used the Unicode-aware trim. I now strip only [ \t\f\r] before deciding whether a line is blank, a comment or a key, and hand that same string to the record matcher. ASCII indentation still parses as before. The inventory test covers the refusal when a hidden override carries the padding, and the domain tests cover the three Unicode spaces for keys, blank lines and comments.
Contributor
[Medium impact] The PR appears safe to merge; no blocking issue was found. SummaryThe PR makes
Reviews (3) · Last reviewed commit: "fix(desktop): skip only ASCII whitespace..." · Reviewed by Greptile |
Shelden-Hao
marked this pull request as ready for review
November 21, 2026 15:33
chukwudinwabuisi26-hub
approved these changes
Nov 21, 2026
gensokyo-dev
approved these changes
Nov 21, 2026
gensokyo-dev
left a comment
Collaborator
There was a problem hiding this comment.
Verified: the new desktopEntry cases fail on main and pass here; LinuxApplicationInventory and desktopEntry suites pass (116 tests). Leading-space set matches the existing GLib group padding rule. Thanks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a parse drift in the desktop-entry reader: REA stripped each line with JavaScript's Unicode-aware
trimStart(), while GLib skips onlyg_ascii_isspacebefore a key. A record indented with U+00A0, U+3000 or U+FEFF was read as a normalName=/Hidden=line by REA and as a malformed record by GLib.This follows #12708, which closed the same gap for group headers by validating the captured padding against GLib's ASCII set. The blank-line, comment and key checks still used the Unicode-aware trim.
Problem and expected behavior
Smallest trigger:
GLib keeps the U+00A0 in the key, so it never reads
Hiddenand the entry stays visible. REA readhidden: trueand nomalformed_line, sofindHiddenDesktopEntry()claimed the deletion that masks the application.Violated invariant: the hidden override may only claim a deletion after the entry establishes its structure (
Claim deletion only after the hidden entry establishes its structure). A padding the format owner rejects must not create that claim.Expected behavior: a line whose leading whitespace is not GLib's ASCII set is malformed, so the override is refused instead of masking the application.
Change and scope
readDesktopEntryFieldsnow strips only[ \t\f\r]before deciding whether a line is blank, a comment or a key, and hands that same string to the record matcher.GROUP.exec(raw)still receives the raw line, because the group branch needs the original padding for its own validation.The ASCII set is the one #12708 and
BOOLEAN_TRUEalready use, so all three checks in this reader now agree on what GLib skips.Not included: the APT reader and the other desktop readers.
aptRepositories.tsalready routes deb822 lines throughtrimDeb822Line, whose comment states it matches APT's ASCII whitespace; changing unrelated readers would widen this diff beyond the reported drift.Contract and boundary impact
readDesktopEntryFieldsinsrc/domain/desktop/desktopEntry.tsowns the line classification. Consumers areparseDesktopEntry,replaceDesktopExecand, through them,LinuxApplicationInventory(findHiddenDesktopEntry, launcher rewrite). No superseded path is left behind: the Unicode trim was the only place that widened the padding.DesktopEntryshape and the refusal reasons are unchanged.linux-desktop-entryonly. The parser is platform-independent and runs on Windows, where the Linux inventory suite is skipped.malformed_line, so an override that GLib would not honour is refused withdesktop_entry_invalidinstead of producing a hidden claim.findHiddenDesktopEntryrefuses the entry; it does not delete anything new.Expected effects:
Evidence and regression coverage
Tests added or updated: three
parseDesktopEntrycases for a key indented with U+00A0, U+3000 and U+FEFF; two cases asserting such a line is neither blank nor a comment; one regression case keeping ASCII space and tab indentation parsed withoutmalformed_line; two rows in therefuses a hidden override with malformed structuretable for inventory.Base reproduction or other evidence: reverting only the source change (keeping the new tests) fails 6 of them, while the ASCII regression case still passes:
User-visible CLI/MCP output: not applicable; no output shape changes.
Remaining proof gaps: the
LinuxApplicationInventorysuite isdescribe.skipIf(process.platform === "win32"), so the two inventory rows only execute in CI on Linux. No real GLib run was available here; the expected behaviour is taken fromg_ascii_isspaceand from the ASCII set fix(desktop): validate group padding before hidden ID masking #12708 already established in this file.Validation performed
node node_modules/vitest/vitest.mjs run src/domain/desktop/desktopEntry.test.ts— 45 passednode node_modules/vitest/vitest.mjs run src/domain/desktop/desktopEntry.test.ts src/desktop/LinuxApplicationInventory.test.ts— 45 passed, 71 skipped (Windows host)node node_modules/oxfmt/bin/oxfmt --check src/domain/desktop/desktopEntry.ts src/domain/desktop/desktopEntry.test.ts src/desktop/LinuxApplicationInventory.test.ts— all matched files use the correct formatnode scripts/run-typescript.mjs --noEmit— exit 0node node_modules/oxlint/bin/oxlint src/domain/desktop/desktopEntry.ts src/domain/desktop/desktopEntry.test.ts src/desktop/LinuxApplicationInventory.test.ts— 0 errors; the two warnings (no-control-regexon the existing group-name class,complexityon the existing reader) are present on the base revision tooCompatibility, safety, and release
Author readiness
Human owner: @Shelden-Hao
Before merge
type(scope): outcome.