#350: Fix double-escaped apostrophe in bad-branch-name-was-punished bylaw#437
Merged
yegor256 merged 2 commits intoApr 29, 2026
Merged
Conversation
…unished bylaw The Liquid template stored "doesn\\\'t" (three backslashes plus an apostrophe) in the explain string. Liquid passes the bytes through unchanged, then Factbase::Syntax consumes one backslash to escape the apostrophe inside the double-quoted token, leaving "doesn\\'t" in the rendered bylaw markdown. A single "\\'" is enough to escape the apostrophe for the S-expression tokenizer, and yields the expected "doesn't" output.
|
@bibonix Thanks for the contribution! You've earned +20 points for this: +24 as a basis; -4 for contributing fewer than 30 hits-of-code (13 total). Please keep them coming! Your running score is +90; don't forget to check your Zerocracy account too. |
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.
@yegor256 this PR fixes #350 — the bylaws page rendered
doesn\\'t(backslash + apostrophe) instead ofdoesn't.Root cause
assets/bylaws/bad-branch-name-was-punished.fe.liquidstored the explain string with three backslashes before the apostrophe:Liquid passes the raw bytes through unchanged.
Factbase::Syntax(factbase-0.19.9/lib/factbase/syntax.rb) then tokenises double-quoted literals and consumes exactly one backslash that precedes a quote character, leavingdoesn\\'t(two backslashes + apostrophe) inside the parsed S-expression. That string is then formatted into the bylaw's markdown, which is what shows up on the vitals page.Since the tokenizer only needs a single backslash to escape an apostrophe inside a double-quoted token, the template only needed
\'rather than\\\'.Changes
test/fbe/test_bylaws.rb— newtest_apostrophes_are_not_double_escapedwalks every bylaw, renders the markdown, and asserts/\\'/does not match. Before the fix it failed only onbad-branch-name-was-punished; after the fix it passes for all 10 bylaws.assets/bylaws/bad-branch-name-was-punished.fe.liquid— changedoesn\\\'ttodoesn\'t. The rendered markdown is nowIf a branch has a name that doesn't obey the convention, ….Verification
bundle exec rake(test + rubocop + picks + yard) passes locally on Ruby 3.3.6.-12with defaultanger=2).The fix is intentionally minimal — only the one over-escaped string is touched; no other bylaws contain apostrophes today, but the new test will catch any future regression in any of them.