Skip to content

Escape font names before rewriting terminal and fontconfig files - #12457

Closed
cYoren wants to merge 1 commit into
omacom:quattrofrom
cYoren:fix/font-set-escaping
Closed

cYoren wants to merge 1 commit into
omacom:quattrofrom
cYoren:fix/font-set-escaping

Conversation

@cYoren

@cYoren cYoren commented Sep 18, 2026 •

Copy link
Copy Markdown

Problem

omarchy-font-set interpolates the raw font name into its sed replacements and into the fontconfig XML. The kitty branch escapes metacharacters, but the alacritty, ghostty and foot branches — and the XML — do not.

  • A name containing the sed delimiter (/) or & breaks the rewrite: sed: -e expression #1, char 32: unknown option to 's', leaving the config untouched (or corrupted).
  • A name containing &, < or > produces invalid XML, so ~/.config/fontconfig/fonts.conf fails to parse and the chosen monospace family is not applied.

Reproduction

# with the font present
omarchy-font-set 'Fake/Font & Friends'

Before:

sed: -e expression #1, char 32: unknown option to 's'
# alacritty.toml still reads family = "Old Font"
# fonts.conf contains a raw, invalid <string>Fake/Font & Friends</string>

After the fix the three terminal configs keep Fake/Font & Friends verbatim and fonts.conf holds <string>Fake/Font &amp; Friends</string>.

Fix

Escape the name once per target syntax right after validation:

  • sed_font_name — for the alacritty/kitty/ghostty/foot replacements (same escaping the kitty branch already used, now shared).
  • xml_font_name — &/</> escaped for the fontconfig text node.

Test

Added test/shell.d/font-set-escaping-test.sh. It stubs fc-list to report a font whose name contains both / and &, stubs pkill/omarchy-restart-shell so no live terminal or shell is signalled, and runs the real bin/omarchy-font-set. It asserts all four terminal configs and the XML keep the name intact.

  • Red on the original script: alacritty rewrite fails and the test reports not ok.
  • Green after the fix: all five assertions pass.
  • The file is picked up by test/shell, which globs test/shell.d/*-test.sh; it also runs on its own with bash test/shell.d/font-set-escaping-test.sh.

@llstrk

llstrk commented Sep 25, 2026

Copy link
Copy Markdown

Automated AI review

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Verified: the change does what the description says. No issue was found in the production change within the tested scope. The shared sed escape (\, &, /) is correct for the /-delimited replacements in both the basic and -E sed calls, and the XML escape (& first, then <, >) is correct for the fontconfig text node. Ordinary font names produce byte-identical output before and after the change.

Result for the PR's example name Fake/Font & Friends, run against the shipped terminal configs in an isolated fixture:

target            merge-base                              this PR
alacritty.toml    unchanged ("Old Font"), sed error       family = "Fake/Font & Friends", parses as TOML
kitty.conf        correct (already escaped)               correct, rewrite and append branches
ghostty/config    unchanged, sed error                    font-family = "Fake/Font & Friends"
foot.ini          unchanged, sed error                    font=Fake/Font & Friends:size=9
fonts.conf        raw "&", rejected by fontconfig         &amp;, accepted, family prepended to monospace

Verified: a name with & but no / (for example A & B) was silent corruption on the merge-base and is fixed. The unescaped & inserted the whole matched text, so alacritty.toml became invalid TOML (family = "A family = "JetBrainsMono Nerd Font", style = "Regular" B") and ghostty and foot received wrong values, with exit status 0 and no error output.

Verified: the new test is picked up by test/shell, fails on the merge-base at the alacritty assertion with the documented unknown option to 's' error, and passes on this head. It writes only inside its mktemp -d directory. The diff applies cleanly to the current quattro tip, and the new test passes there.

Optional test improvement: the test stubs pkill but not pgrep, so the script's pgrep -x ghostty and pgrep -x foot calls query the live process table and can print PIDs into test output on a developer machine. Nothing is signalled. A pgrep stub that exits 1, as test/shell.d/kitty-config-test.sh already uses for the same script, makes the test hermetic. The description also lists </> escaping, which no assertion exercises; a name such as Fake/Font & <Friends> would cover it in all five checks.

Description note: the Test section says the new functions-loading-test.sh still passes, but no file by that name exists in this PR or on quattro.

Pre-existing, outside this PR: a family name containing " or \ still produces an invalid alacritty TOML string, because the sed escape does not add TOML escaping. The merge-base is also broken for these characters, and no shipped or commonly installed monospace font with them was identified.


Review information

Test scope: source review of bin/omarchy-font-set, its callers and the shipped terminal configs, plus isolated command-only runs of the new test (merge-base, head and the current quattro tip) and of the script against synthetic font names and shipped configs, with process and notification helpers stubbed. Output was checked with TOML and XML parsers and fontconfig's own parser. No terminal emulator was launched, so terminal-side acceptance rests on upstream source and documentation.

AI process: Opus 5.5 Medium coordination and synthesis, independent Opus 5.5 Xhigh and GPT 6 Sol Xhigh technical assessments, Opus 5.5 Medium editorial check.

Opt out: To stop receiving these reviews, reply to this comment saying so.

@omarchybot omarchybot added the bug Something isn't working label Sep 27, 2026
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Oct 1, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at 6ad4dea and verified on an Omarchy ISO worker. Nothing to change.

What was checked. I wrote a separate reproduction instead of relying on the test in this PR. It runs the real bin/omarchy-font-set against fixture configs with the names Fake/Font & Friends, A & B Mono, Mono <Nerd> & Co, a plain name, and a /+& name in a kitty.conf with no font_family line (the append branch). It then checks all four terminal configs, parses alacritty.toml as TOML, and runs xmllint on fonts.conf.

  • On quattro (8b4eae6), and on this head with bin/omarchy-font-set reverted, it fails: the alacritty, ghostty and foot rewrites stop with unknown option to 's'. A name with & but no / fails silently: alacritty.toml becomes invalid TOML and fonts.conf is not well-formed XML.
  • On this head, and on this head merged into current quattro, every case passes. Plain names produce identical output.
  • test/cli passes. In test/shell, font-set-escaping-test.sh and kitty-config-test.sh pass. Three files fail: ascii-test.sh, branding-about-animation-test.sh and omarchy-kernel-migration-test.sh. They fail the same way on quattro without this PR, so they are not caused by it.

Second opinion. Codex Medium reviewed the diff pinned to this head. It found the change proportionate and the sed and XML escaping complete for a text node, and it agreed the test is not vacuous. Its agreement is not guaranteed to be independent. It also named two limits that are already broken on quattro and are outside what this PR fixes: a name with a line break still breaks the sed rewrites, and a backslash or double quote in a name still makes an invalid string in alacritty.toml.

Other pull requests. #10811 and #8179 also escape font names. This one is the narrower fix. #10811 refuses names containing &, < or > instead of writing them, bundles a change to the fc-list lookup, and its new xml_escape function fails bash -n (the unescaped " and ' in ${value//"/&quot;}). #8179 is mainly about XDG_CONFIG_HOME and currently conflicts with quattro.

What happens next. This waits on the maintainer. The PR has no CI checks, and the shell suite is not fully green on the worker for the reasons above.

@jandrusk

Copy link
Copy Markdown

Correct sed/XML escaping for font names with &///<>. Has tests; omarchybot verified. Ready.

@omarchybot omarchybot removed the verified Omarchy Triage has verified that this issue is ready for final review label Oct 31, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Looked at this again after #6958 (preserve the foot font size) merged to quattro. The escaping fix still stands, but the PR now conflicts, and it competes with #10811. It is waiting on the maintainer.

After #6958. #6958 does not escape font names, so nothing here is made redundant. Both PRs change the same foot line, though, so this branch no longer merges cleanly. The resolution has to keep both changes: sed -i "s/^font=.*/font=$sed_font_name:size=$foot_size/g". Putting back size=9 would undo #6958. The test's foot fixture uses size 9, so it would pass either way; a fixture with a different size would cover both behaviours. I removed verified because the earlier verification was done against a base this PR no longer merges onto.

Competing fix. #10811 is older (opened 2026-09-08) and was rebased onto current quattro today. It fixes the same sed breakage, but it handles &, < and > differently: it refuses those names instead of escaping them. It also refuses quotes, backslashes and newlines, escapes foot's pattern syntax (-, ,, :) and looks fonts up by family. Each PR covers something the other does not. This one writes a & name correctly; that one rejects a " or \ that would break alacritty.toml. I don't read either as clearly better, so by the oldest-first default #10811 is the one to carry forward. I've queued this PR's approach to be folded into it: escape &, < and > for sed and XML instead of rejecting them, crediting you as co-author.

Who checked. Claude Opus 5.5 read both diffs against quattro at d367a56. Codex Medium reviewed each question separately. It agreed this PR is not made redundant by #6958 and gave the same foot resolution. On the competing fix it disagreed with me: it picked this PR, on the grounds that refusing & names misses a case this one handles. Its agreement on the first point is not guaranteed to be independent. Because the two reviews split on the second, choosing between #10811 and this PR is left to the maintainer. No tests were run this time: nothing new was pushed, and the conflict has to be resolved before there is anything to run.

omarchybot added a commit to chessing234/omarchy that referenced this pull request Nov 1, 2026
Families such as "Fira Code & Friends" are real, and nothing about them is dangerous: sed already escapes & and / in every replacement, and fonts.conf only needs the XML text node escaped. Refuse only what could close a string in a terminal config.

From omacom#12457.

Co-Authored-By: Ovatsug Rasec (Gus) <32225578+cYoren@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cYoren

cYoren commented Nov 17, 2026

Copy link
Copy Markdown
Author

thanks for the recheck. the conflict is on the foot line after #6958, and the resolution has to keep both: the escaped name and the size from #6958.

if #10811 ends up carrying the escaping forward, that is fine by me and i would rather not add noise here. leaving the call with the maintainer.

@omarchybot

Copy link
Copy Markdown
Collaborator

@cYoren the escaping from this PR is now in #10811, as of 5506dfc, with you credited as co-author. You don't need to resolve the foot conflict here unless the maintainer picks this PR over #10811.

What was checked. Claude Opus 5.5 compared the two diffs target by target, and Codex Medium did the same comparison on its own. Both found that #10811 now makes every script change this PR makes. The alacritty, kitty, ghostty and fontconfig lines escape names exactly as they do here. On foot it escapes more, adding fontconfig's -, , and :, and it keeps the size from #6958. Its test covers a name containing / & < >, which is broader than the test here (/ and &). Codex read both diffs after the earlier comments were posted, so its agreement is not guaranteed to be independent. Nothing was run this time: this branch hasn't changed, and the fold was verified on a worker when it landed on #10811.

The one difference. #10811 refuses names containing a quote, backslash, backtick, $, ; or a line break. This PR would write those names. A quote or backslash would break alacritty.toml and the ghostty config, so refusing them is a fix. Refusing $, a backtick or ; is a policy choice, and it would only matter for an unusually named font.

Waiting on. The maintainer's choice between the two. If #10811 is merged, this PR has nothing left to add and can be closed.

@cYoren
cYoren force-pushed the fix/font-set-escaping branch from 6ad4dea to 80a4f64 Compare November 17, 2026 05:11
@cYoren

cYoren commented Nov 17, 2026

Copy link
Copy Markdown
Author

rebased onto current quattro at 80a4f64, and the foot conflict with #6958 is resolved by keeping both changes: the sed rewrite now interpolates the escaped name and the size that is already in foot.ini.

the test fixture starts at size 12 instead of 9, so it fails if the size gets reset, not just if the escaping breaks.

checked end to end on a temp HOME with a stubbed fc-list:

  • alacritty: family = "Fake/Font & Friends"
  • kitty: font_family Fake/Font & Friends
  • ghostty: font-family = "Fake/Font & Friends"
  • foot: font=Fake/Font & Friends:size=12 (size from the file, not 9)
  • fonts.conf: <string>Fake/Font &amp; Friends</string>
  • running it twice gives the same result.

still leaves the two limits the previous review named: a newline in a name, and a backslash or quote in alacritty.toml. those are broken on quattro too and out of scope here.

@greptile-apps

greptile-apps Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] No new blocking issue was found.

Summary

Escapes font names before writing terminal settings and fontconfig XML.

  • Special-character font names now work across terminals and fontconfig.

Reviews (4) · Last reviewed commit: "Escape font names before rewriting the t..." · Reviewed by Greptile

Comment thread test/shell.d/font-set-escaping-test.sh Resolved
@omarchybot

Copy link
Copy Markdown
Collaborator

@cYoren thanks for the rebase. I read 80a4f64 against quattro. The foot line now writes the escaped name with the size quattro reads from foot.ini, so #6958's change is kept, and the branch merges cleanly again. The fixture starting at size 12 does cover both behaviours. Nothing was run this time, for the reason below.

Still competing with #10811. #10811 is older and makes the same alacritty, kitty, ghostty and fontconfig changes as this PR. Two differences remain, one on each side:

  • Foot pattern syntax. Look up the font family instead of dumping fc-list #10811 also escapes -, , and : in the foot font, and this PR does not (neither does quattro). Foot reads that line as a fontconfig pattern. I checked with fc-pattern: Test-Mono:size=12 parses as family Test, while Test\-Mono:size=12 parses as Test-Mono.
  • Refused names. Look up the font family instead of dumping fc-list #10811 refuses names containing a quote, backslash, backtick, $, ; or a line break. This PR writes them. Refusing a quote or backslash is a fix, since either breaks alacritty.toml. A $, backtick or ; writes correctly, so refusing them turns away an unusual but valid name.

Who checked. Claude Opus 5.5 read both diffs. Codex Medium compared them separately and picked this PR, because #10811 refuses the $, backtick and ; names. Codex also raised the foot hyphen case, which I then confirmed. Since each PR handles a case the other misses, I don't read either as clearly better, so the oldest-first default favours #10811. The two reviews disagree, so the choice stays with the maintainer.

If this PR is the one picked: AGENTS.md asks for the area's existing test file to be extended rather than a new one added. test/shell.d/kitty-config-test.sh already runs omarchy-font-set, so these checks would go there. This is the same point Greptile raised, and it applies to #10811's two new test files as well.

Waiting on the maintainer.

@cYoren

cYoren commented Nov 20, 2026

Copy link
Copy Markdown
Author

moved the escaping checks into test/shell.d/kitty-config-test.sh in 3e548a7, reusing its stubs, and deleted the separate font-set-escaping-test.sh, which is what AGENTS.md asks for (extend the area's existing test, do not add another *-test.sh).

verified both ways: with the base bin/omarchy-font-set the new checks go red on the sed error (unknown option to 's', alacritty keeps "Old Font"); with this branch's command the same file passes, including the foot size 12 that #6958 introduced.

Comment thread test/shell.d/kitty-config-test.sh Resolved
@omarchybot

Copy link
Copy Markdown
Collaborator

Read 3e548a7, including the move into test/shell.d/kitty-config-test.sh, the reused stubs and the foot size-12 assertion. The separate escaping test is gone, so the earlier test-placement finding is addressed. The production command is unchanged from 80a4f64.

GPT-6 in Codex performed this source review; its reasoning effort is not exposed by this session. I classify the change as a bug fix, but the second classifier, deepseek-v4p1-flash, returned no usable classification for this head. The general reviewer answered its availability check, but that check is not a review of this PR. Classification therefore remains unsettled, and this run stops before worker tests or verification labels. Nothing was pushed.

This waits for the missing second classification before verification can continue. The previously discussed choice involving #10811 remains with the maintainer.

@omarchybot omarchybot removed the bug Something isn't working label Nov 20, 2026
@cYoren

cYoren commented Nov 21, 2026

Copy link
Copy Markdown
Author

seeded font_family Old Font in the kitty config before running the command in c7977c8, so the check now takes the sed replacement branch instead of the append one.

two assertions back it: exactly one font_family line afterwards, and the seeded family is gone. dropped the sed escaping from omarchy-font-set and the check fails, so the branch is really exercised now.

@omarchybot

Copy link
Copy Markdown
Collaborator

Read c7977c838210de1f2dac1e99b49f2a0513c24b83 against quattro, including the latest test change and both inline findings. The Kitty fixture now has an active font_family Old Font, so the escaping check reaches the replacement branch. The added assertions check that exactly one family setting remains and the old value is gone. The production command is unchanged.

GPT-6 in Codex performed this source review; the session does not expose its reasoning effort. I classify this as a bug fix, but the configured second classifier, deepseek-v4p1-flash, returned no usable classification for this head. Under the queue workflow, that leaves classification unsettled and stops verification here. No worker tests ran, no code was pushed, and no verification labels were added. This waits for a usable second classification; the earlier choice involving #10811 has not been reconsidered in this run.

@omarchybot omarchybot added the bug Something isn't working label Nov 22, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Classification is now agreed as bug, so the missing second classification reported above is resolved.

GPT-6 in Codex (reasoning effort not exposed) compared c7977c838210de1f2dac1e99b49f2a0513c24b83 with current quattro, its callers, and the current diffs of #10811 and #8179. Opus 5.5 High and muse-wonder via pi, thinking high reviewed the comparison. Both agreed that #10811 at 5506dfcf040d5852c17c75342a511335c4578b70 already carries this PR's sed and XML escaping. Their agreement is not guaranteed to be independent. #10811 makes additional changes, so these are competing fixes; #8179 is a separate XDG enhancement.

This waits on the maintainer's choice between the competing fixes. No worker tests ran and nothing was pushed in this run; the earlier verification applies to an older head.

@cYoren
cYoren force-pushed the fix/font-set-escaping branch from c7977c8 to 4918e17 Compare November 23, 2026 20:34
@cYoren

cYoren commented Nov 23, 2026

Copy link
Copy Markdown
Author

rebased onto quattro at e5d9caea9, so the branch applies again. the conflict came from #19904 moving the shell tests: test/shell.d/kitty-config-test.sh is gone upstream, so the escaping test now lives in test/shell.d/font-set-escaping-test.sh, carried over from the old file.

the source change is unchanged: escape once into sed_font_name and xml_font_name and use them in the alacritty, kitty, ghostty and foot replacements and the fontconfig XML. kitty's own kitty_font_name folded into the shared one.

verified at 4918e17: bash test/shell.d/font-set-escaping-test.sh passes all five assertions, and against the base bin/omarchy-font-set it prints not ok on alacritty with the same sed: unknown option to 's' error.

#10811 still carries the same escaping, so it is still your call which one lands.

@omarchybot

Copy link
Copy Markdown
Collaborator

Read the rebase at 4918e17caf73efa87313359a74f84b92cd7b0912 against current quattro. The production script is unchanged from c7977c8. #19904 removed kitty-config-test.sh; the restored escaping test still seeds an active Kitty family and Foot size 12, preserving those checks in source.

The same sed and XML escaping remains in older #10811, which also changes font lookup, accepted names and Foot pattern handling. These remain competing changes; this run makes no new choice between them.

GPT-6 in Codex performed this source review; its reasoning effort is not exposed. Both classifiers agree this head is a bug fix. The required Opus 5.5 High second review could not run because its weekly usage limit was reached, and its availability check also failed. No full second opinion ran on this head.

No worker tests ran, nothing was pushed, and no verification labels were added. This remains waiting on the maintainer's choice and a completed second review.

@dhh

dhh commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Thank you @cYoren! This has been superseded by #19969, which landed sed, quote, and XML escaping for font names in bin/omarchy-font-set (along with symlink preservation and regression tests in test/shell.d/desktop-helpers-test.sh).

@dhh dhh closed this Nov 24, 2026
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.

5 participants