Skip to content

fix(webvtt): accept whitespace in cue timing lines - #294

Merged
dmtrKovalenko merged 1 commit into
dmtrKovalenko:mainfrom
kremnyi:codex/webvtt-cue-timing-whitespace
Dec 3, 2026
Merged

dmtrKovalenko merged 1 commit into
dmtrKovalenko:mainfrom
kremnyi:codex/webvtt-cue-timing-whitespace

Conversation

@kremnyi

@kremnyi kremnyi commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Addresses the whitespace case in #280. A tab before --> and a form feed after it make Vtt::parse reject the whole file. The parser expects exactly one space on each side.

Skip spaces, tabs and form feeds before each timestamp and before the arrow, as specified in the WebVTT cue timing algorithm. The regression test compares the resulting cue, including its identifier, alignment and text, with the same cue written with single spaces. It also checks that a line break or vertical tab cannot join two timestamps.

Tested with cargo test --locked -p webvtt-parser, cargo fmt --check -p webvtt-parser and cargo clippy --locked -p webvtt-parser --all-targets -- -D warnings.

Summary by CodeRabbit

  • Bug Fixes
    • Cue timing lines now accept spaces, tabs, or form-feed characters around the start time and --> separator, as well as no whitespace around the separator.
    • Newlines and vertical tabs between the start time and separator remain invalid.

@coderabbitai

coderabbitai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Cue timing parsing now accepts spaces, tabs, form feeds, or no whitespace before the start time and around the --> separator. Tests cover these cases and reject newlines and vertical tabs between the start time and separator.

Changes: Cue Timing Whitespace

Layer / File(s) Summary
Timing whitespace parsing
webvtt-parser/src/vtt_parser.rs, webvtt-parser/src/lib.rs
The parser consumes optional spaces, tabs, and form feeds before the start time and before -->. Tests cover accepted whitespace and rejection of newlines and vertical tabs between the start time and separator.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Possibly related issues

  • dmtrKovalenko/fframes#280: The issue reports rejected tabs and form feeds around -->; this change permits those whitespace characters.

Possibly related PRs

Suggested reviewers: dmtrkovalenko

Merge Risk: Minimal · up to 03bd1

The parser now accepts tabs, form feeds, or no whitespace around the cue timing separator, matching the WebVTT cue timing algorithm. No actionable merge risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "fix(webvtt): accept whitespace in cue timing lines" matches the main change. The raw summary shows parse_cue now accepts spaces, tabs, and form feeds around the start time and the --> separ…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "fix(webvtt): accept whitespace in cue timing lines" matches the main change. The raw summary shows parse_cue now accepts spaces, tabs, and form feeds around the start time and the --> separator, and a test covers this. The PR objectives describe the same fix for issue #280. The title is specific and concise, and it names the affected component (webvtt) and the type of change (fix).

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f9726d3a-8f52-41ca-983f-eb367ab3cd97
Commits

Reviewing files that changed from the base of the PR and between b33f46b and 03bd14d.

Files selected for processing: 2

  • webvtt-parser/src/lib.rs
  • webvtt-parser/src/vtt_parser.rs

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

@dmtrKovalenko
dmtrKovalenko merged commit 3292590 into dmtrKovalenko:main Dec 3, 2026
13 checks passed
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.

2 participants