You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(webvtt): accept a leading byte-order mark - #293
WebVTT files with a leading UTF-8 byte-order mark were rejected at the signature. Accept one leading mark while keeping error offsets relative to the original file. A malformed signature still fails.
The new regression failed on the previous parser. cargo test --locked -p webvtt-parser now passes all 10 unit tests and the doc test. cargo fmt -p webvtt-parser -- --check also passed.
AI assistance: Codex.
Summary by CodeRabbit
Bug Fixes
Valid WebVTT documents with a leading UTF-8 BOM now parse correctly. Repeated BOMs and BOM-prefixed input without a valid WEBVTT marker return errors, with error offsets accounting for the BOM. For parse errors after a BOM, the reported line and fragment remain consistent with the input, while the byte offset reflects the BOM’s length.
No actionable comments were generated in the recent review.
Walkthrough
The parser now accepts one leading UTF-8 BOM before the WEBVTT marker. Tests cover parsed cues, rejection of repeated BOMs and invalid headers, and error offsets for BOM-prefixed invalid documents.
Changes: Leading BOM parsing
Layer / File(s)
Summary
BOM handling and validation webvtt-parser/src/vtt_parser.rs, webvtt-parser/src/lib.rs
parse consumes an optional leading BOM before checking for the WEBVTT marker. Tests cover accepted and rejected inputs, and verify that the BOM increases the error offset without changing the line or fragment.
This change lets WebVTT files that start with a single byte-order mark parse correctly. Malformed signatures still fail, and error offsets still point into the original file. No merge-blocking risk was found.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title "fix(webvtt): accept a leading byte-order mark" matches the main change. The PR makes the WebVTT parser accept one optional UTF-8 BOM before the WEBVTT signature, and adds tests for that cas…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title "fix(webvtt): accept a leading byte-order mark" matches the main change. The PR makes the WebVTT parser accept one optional UTF-8 BOM before the WEBVTT signature, and adds tests for that case, for doubled BOMs, and for error offsets after a BOM. The title is specific, concise, and follows a conventional commit style.
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.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: defaults
Review profile: CHILL
Plan: Advanced
Run ID: 280778c4-4e6a-41b4-9db8-e998fbb9acbc
Commits
Reviewing files that changed from the base of the PR and between b8f286e and 6ba68f7.
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.
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
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.
WebVTT files with a leading UTF-8 byte-order mark were rejected at the signature. Accept one leading mark while keeping error offsets relative to the original file. A malformed signature still fails.
Refs #280 (BOM case only).
The new regression failed on the previous parser.
cargo test --locked -p webvtt-parsernow passes all 10 unit tests and the doc test.cargo fmt -p webvtt-parser -- --checkalso passed.AI assistance: Codex.
Summary by CodeRabbit
WEBVTTmarker return errors, with error offsets accounting for the BOM. For parse errors after a BOM, the reported line and fragment remain consistent with the input, while the byte offset reflects the BOM’s length.