forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits

script.rs28 lines, 826 bytesHistoryRawDownload
1#![no_main]
2
3use ec_subs::{SubtitleTrack, plain_text};
4use libfuzzer_sys::fuzz_target;
5
6
7// Every cue is well formed, and every style reference resolves or is absent.
8fn check(track: &SubtitleTrack) {
9 for cue in &track.cues {
10 assert!(cue.end_us >= cue.start_us);
11 let _ = plain_text(&cue.segments);
12 if let Some(name) = &cue.style_ref {
13 let _ = track.style(name);
14 }
15 }
16}
17
18// A whole ASS/SSA script: the section headers, Format lines, every Style and Dialogue row, and the
19// override tags inside them. Bytes as they are, then lossy UTF-8.
20fuzz_target!(|data: &[u8]| {
21 if let Ok(track) = ec_ass::parse(data) {
22 check(&track);
23 }
24 let text = String::from_utf8_lossy(data);
25 if let Ok(track) = ec_ass::parse(text.as_bytes()) {
26 check(&track);
27 }
28});