fix: harden against confirmed review findings - #2
Conversation
Adds a "Coming from Python" on-ramp table (verified against the repo's own examples/ and tests) and corrects suite/test-count accuracy issues. Co-Authored-By: Claude <noreply@anthropic.com>
A cue whose text contains `-->` (e.g. "Use map --> filter here.") parsed as zero cues: `_parse_block` treated any line containing the substring `-->` as a timing line, so the text line was taken as a new cue boundary, then failed to parse as `timestamp --> timestamp` and threw away the whole block. Add `_is_timing_line`, which only treats a line as a cue boundary when both sides parse as timestamps, and use it for both the first-timing- line scan and the glued-cue boundary scan. Also isolate each segment's `_parse_timing` in its own try so a malformed timing line skips only that segment instead of discarding cues already gathered from the block. Also fix the pixi mojo pin (`>=1.0.0b3` sorts below dev nightlies, so `pixi install` failed to solve) to `>=1.0.0b3.dev0,<2` as a build prerequisite for verifying the fix. Adds regression tests for `-->` in single-line and multi-line cue text and for a genuinely glued second cue whose predecessor's text holds a `-->`. Full suite: 32 tests, all passing. Co-Authored-By: Claude <noreply@anthropic.com>
… parallel docs branch The Coming-from-Python README section belongs to the docs PR, not this security/robustness fix branch. Co-Authored-By: Claude <noreply@anthropic.com>
|
🤖 Independent Claude review: Ready to mark for review. Adversarial second look — no blocking correctness/security issue found. I traced every changed path by hand against the source (no mojo toolchain in this sandbox, so I did not recompile; relying on the author’s green run for compilation). Verified:
Non-blocking nits (optional):
|
|
Code review (opus, static — verify CI): SHIP The Nits (informational): the |
Hardens the parser against one confirmed review finding. From an automated multi-agent review (personal-context#62); implemented + verified by Claude Code.
Fix 1 —
-->in cue text destroys the block (correctness)_parse_blocktreated any line containing the substring-->as a timing line. A legal cue whose text contains-->(prose, code, an arrow gloss) was therefore read as a cue boundary, failed to parse astimestamp --> timestamp, and the raised error discarded the entire block.Fix: added
_is_timing_line, which only treats a line as a cue boundary when both sides parse as timestamps, and used it for both the first-timing-line scan and the glued-cue boundary scan. Also isolated each segment's_parse_timingin its owntryso a malformed timing line skips only that segment instead of discarding cues already gathered from the block.Before/after evidence (input
"1\n00:00:01,000 --> 00:00:02,000\nUse map --> filter here.\n"), run against the known-good Mojo nightly:Regression tests added in
test/test_captions.mojo:test_arrow_in_cue_text_not_a_boundary— single-line-->text, plusto_srt/to_vttround-tripstest_arrow_in_multiline_text_preserved—-->on a later text line doesn't truncate the cuetest_arrow_text_still_splits_glued_real_cue— a genuinely glued second cue is still split even when the first cue's text holds a-->Bundled build prerequisite — pixi pin
The repo's
pixi.tomlpinnedmojo = ">=1.0.0b3,<2", which sorts below dev nightlies, sopixi installfailed to solve (No candidates were found for mojo >=1.0.0b3,<2). Fixed to>=1.0.0b3.dev0,<2(same fix already confirmed in mojo-redis) so the fix could be built and tested.Build + tests
pixi installnow solves.pixi run test: 32 tests run, 32 passed, 0 failed, 0 skipped (29 pre-existing + 3 new). No live external servers involved.test/fuzz_runner.mojoandexamples/clip_transcript.mojoboth build clean against the changed module.Notes
-->-bearing text.