Skip to content

fix: accept case-insensitive booleans in grammar validators - #550

Merged
SJrX merged 3 commits into
242.xfrom
fix/boolean-case-insensitive
Oct 24, 2026
Merged

SJrX merged 3 commits into
242.xfrom
fix/boolean-case-insensitive

Conversation

@SJrX

@SJrX SJrX commented Oct 24, 2026

Copy link
Copy Markdown
Owner

systemd's parse_boolean() compares with STRCASE_IN_SET, so values such as PrivateTmp=True or PrivateUsers=False are valid, but the shared BOOLEAN and BOOLEAN_FALSE terminals (and deprecatedBoolean) matched case-sensitively. They now pass ignoreCase = true; the lower-case spellings remain canonical for quick-fixes. A new BOOLEAN_TRUE terminal covers ProtectHostname=yes:HOST.

Validators that inlined the twelve boolean spellings into one case-sensitive choice are restructured as names-first-then-boolean via a new namesOrBoolean() helper, mirroring string_table_lookup_from_string_with_boolean: only the boolean half ignores case, the table names stay case-sensitive (PrivateTmp=Disconnected is still rejected). Name lists now match the C tables at 0f0682b773 (e.g. PrivateTmp=connected, RuntimeDirectoryPreserve= on-success, Timezone=symlink/delete/auto, PrivateUsersOwnership=foreign/auto, DHCP= deprecated none/both/v4/v6), and MulticastRouter= accepts only false booleans because its table maps "yes" to _MULTICAST_ROUTER_INVALID.

namesOrBoolean uses a new PreferValidAlternativeCombinator so that, under the classic engine, a lower-case names terminal's lenient shape match cannot strand a mixed-case boolean (the "t" of "tRUE") or a boolean longer than every name (the "fals" of DuplicateAddressDetection=false). CONDITION_VIRTUALIZATION, DuplicateAddressDetection=, DNSSEC= and RestrictNamespaces= use it too.

systemd's parse_boolean() compares with STRCASE_IN_SET, so values such as
PrivateTmp=True or PrivateUsers=False are valid, but the shared BOOLEAN and
BOOLEAN_FALSE terminals (and deprecatedBoolean) matched case-sensitively.
They now pass ignoreCase = true; the lower-case spellings remain canonical
for quick-fixes. A new BOOLEAN_TRUE terminal covers ProtectHostname=yes:HOST.

Validators that inlined the twelve boolean spellings into one case-sensitive
choice are restructured as names-first-then-boolean via a new namesOrBoolean()
helper, mirroring string_table_lookup_from_string_with_boolean: only the
boolean half ignores case, the table names stay case-sensitive
(PrivateTmp=Disconnected is still rejected). Name lists now match the C
tables at 0f0682b773 (e.g. PrivateTmp=connected, RuntimeDirectoryPreserve=
on-success, Timezone=symlink/delete/auto, PrivateUsersOwnership=foreign/auto,
DHCP= deprecated none/both/v4/v6), and MulticastRouter= accepts only false
booleans because its table maps "yes" to _MULTICAST_ROUTER_INVALID.

namesOrBoolean uses a new PreferValidAlternativeCombinator so that, under the
classic engine, a lower-case names terminal's lenient shape match cannot
strand a mixed-case boolean (the "t" of "tRUE") or a boolean longer than every
name (the "fals" of DuplicateAddressDetection=false). CONDITION_VIRTUALIZATION,
DuplicateAddressDetection=, DNSSEC= and RestrictNamespaces= use it too.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Unit Test Results (grammar engine true)

1 322 tests   1 322 ✅  1m 1s ⏱️
  334 suites      0 💤
  334 files        0 ❌

Results for commit f66b5a2.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Unit Test Results (grammar engine false)

1 322 tests   1 322 ✅  58s ⏱️
  334 suites      0 💤
  334 files        0 ❌

Results for commit f66b5a2.

♻️ This comment has been updated with latest results.

SJrX and others added 2 commits October 24, 2026 07:03
…OrBoolean()

Replace the namesOrBoolean() helper with an explicit
PreferValidAlternativeCombinator(FlexibleLiteralChoiceTerminal(<names>), BOOLEAN)
at every call site, so the grammar reads as the combinator structure it is
and the boolean branch is never a hidden default argument.

Also drop the boolean spellings (yes, no, off) from the name lists. They
came from systemd's string tables, whose first entries are the canonical
false/true names, but the boolean branch already accepts them in any case,
so listing them again as case-sensitive names only made the lists
misleading.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…rkaround

Spell out that it only changes the classic SyntacticMatch pass, that it is
identical to AlternativeCombinator under the new engine, and give the
concrete inputs that fail without it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@SJrX
SJrX merged commit b13a2f6 into 242.x Oct 24, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant