summaryrefslogtreecommitdiff
path: root/lib/kernel/overlay_ini.ml
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-08-20 22:11:17 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-08-20 22:11:17 +0200
commit1988d350242b47aa52aa07904c495e7e2c0eba82 (patch)
tree463254012c555da51aa976dbe350415070b80a63 /lib/kernel/overlay_ini.ml
parent2d8942e08edcbe5430f97270bdb1233e287600ee (diff)
downloadcolitur-1988d350242b47aa52aa07904c495e7e2c0eba82.tar.gz
colitur-1988d350242b47aa52aa07904c495e7e2c0eba82.zip
fix: audit findings — parser strictness, name ambiguity, and errors
Found by auditing the shipped program rather than the diff. The parser accepted OCaml integer-literal syntax, so "Luke 1_1:5" read as chapter ELEVEN and "+5" as 5 -- a typo silently becoming a different chapter, reachable through any user overlay. Numbers are now plain digits and positive, and a descending range is rejected: 1:20-10 is always a transcription error. No shipped citation changed. FOUR PAIRS OF DIFFERENT BOOKS SHARED A FULL TITLE. 1 and 2 Corinthians both rendered "Epistola ad Corinthios", as did Thessalonians, Timothy and Peter -- 108 citations in 2027 alone that a reader cannot resolve to a book. This is the Kings defect fixed earlier and not generalised. The titles now carry their volume numeral, marked CONSTRUCTED, and a test asserts no two books share a name -- while allowing the case where two ids ARE the same book under different numbering, which a tradition relates. Spec section 8.5 is now delivered rather than merely recorded. Shipped styles did not re-parse their own output: 32 of 52 Latin abbreviations and 49 of 52 full titles failed, so a citation copied from colitur's own output into an overlay was passed through untouched and printed in the wrong language, silently. Every shipped name is registered as a spelling and split_book learned multi-word titles by longest-token match. Now 0 of 52 fail beyond the same-book aliases. Overlay errors were written for a compiler author: they named an OCaml source file the reader does not have and buried the useful token. The existing five-path rewriter is replaced by a generic one, applied to every load path rather than one, so "rank: is not one of the allowed values (at Class9)" replaces the raw Of_sexp_error dump. Also: the new-overlay scaffold documented citations and layer without showing them, and its comment implied the wrong nesting -- the single easiest thing to get wrong; error messages echoed whole file lines, copying an unrelated file's contents into stderr when a flag pointed at one; and config --show validated partway down its table, exiting 2 after writing five rows to stdout.
Diffstat (limited to 'lib/kernel/overlay_ini.ml')
-rw-r--r--lib/kernel/overlay_ini.ml13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/kernel/overlay_ini.ml b/lib/kernel/overlay_ini.ml
index 6b6249f..09f6d52 100644
--- a/lib/kernel/overlay_ini.ml
+++ b/lib/kernel/overlay_ini.ml
@@ -37,7 +37,18 @@ let parse_sections text =
end
else
match String.index_opt line '=' with
- | None -> err "line %d: %S is neither a [section] nor a key = value line" n line
+ | None ->
+ (* Echo at most a little of the line. Pointing at line N is
+ what locates the problem; reproducing the whole line adds
+ nothing and, when someone has pointed a --lang or --overlay
+ flag at a file that is not a calendar at all, quietly
+ copies that file's contents into stderr and any log
+ collecting it. *)
+ let shown =
+ if String.length line > 40 then String.sub line 0 37 ^ "..."
+ else line
+ in
+ err "line %d: %S is neither a [section] nor a key = value line" n shown
| Some i ->
if !cur = None then
err "line %d: %S appears before any [section] header" n line