Skip to content

#350: Fix double-escaped apostrophe in bad-branch-name-was-punished bylaw#437

Merged
yegor256 merged 2 commits into
zerocracy:masterfrom
bibonix:fix-350-double-escaped-apostrophe
Apr 29, 2026
Merged

#350: Fix double-escaped apostrophe in bad-branch-name-was-punished bylaw#437
yegor256 merged 2 commits into
zerocracy:masterfrom
bibonix:fix-350-double-escaped-apostrophe

Conversation

@bibonix

@bibonix bibonix commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

@yegor256 this PR fixes #350 — the bylaws page rendered doesn\\'t (backslash + apostrophe) instead of doesn't.

Root cause

assets/bylaws/bad-branch-name-was-punished.fe.liquid stored the explain string with three backslashes before the apostrophe:

(explain "If a branch has a name that doesn\\\'t obey the convention, …")

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, leaving doesn\\'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

  1. test/fbe/test_bylaws.rb — new test_apostrophes_are_not_double_escaped walks every bylaw, renders the markdown, and asserts /\\'/ does not match. Before the fix it failed only on bad-branch-name-was-punished; after the fix it passes for all 10 bylaws.
  2. assets/bylaws/bad-branch-name-was-punished.fe.liquid — change doesn\\\'t to doesn\'t. The rendered markdown is now If 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.
  • All 10 CI checks are green: actionlint, copyrights, markdown-lint, pdd, rake (ubuntu-24.04, 3.3), rake (macos-15, 3.3), reuse, typos, xcop, yamllint.
  • The bill points for this bylaw are unchanged (-12 with default anger=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.

bibonix added 2 commits April 29, 2026 16:09
…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.
@yegor256 yegor256 merged commit 91d6dd8 into zerocracy:master Apr 29, 2026
10 checks passed
@0crat

0crat commented Apr 29, 2026

Copy link
Copy Markdown

@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.

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.

Apostrophe is double-escaped in the bylaws §6

3 participants