Repository navigation
fix: accept case-insensitive booleans in grammar validators - #550
Merged
Merged
Conversation
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>
Unit Test Results (grammar engine true)1 322 tests 1 322 ✅ 1m 1s ⏱️ Results for commit f66b5a2. ♻️ This comment has been updated with latest results. |
Unit Test Results (grammar engine false)1 322 tests 1 322 ✅ 58s ⏱️ Results for commit f66b5a2. ♻️ This comment has been updated with latest results. |
…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>
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.
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.