forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits

markup.rs30 lines, 1.0 KiBHistoryRawDownload
1#![no_main]
2
3use ec_subs::{plain_text, srt, webvtt};
4use libfuzzer_sys::fuzz_target;
5
6// The markup both formats share, reached through a one-cue document so the input is always a cue
7// body: the tag stack, entities, colour and font attributes, and (WebVTT) voices, classes and
8// inline timestamps. Also the byte and clock helpers on the raw input.
9fuzz_target!(|data: &[u8]| {
10 let text = ec_subs::decode(data);
11 for field in text.split_whitespace() {
12 let _ = ec_subs::parse_clock(field);
13 }
14 let _ = ec_subs::parse_clock(&text);
15
16 let mut srt_doc = b"1\n00:00:01,000 --> 00:00:02,000\n".to_vec();
17 srt_doc.extend_from_slice(data);
18 if let Ok(track) = srt::parse(&srt_doc) {
19 for cue in &track.cues {
20 let _ = plain_text(&cue.segments);
21 }
22 }
23 let mut vtt_doc = b"WEBVTT\n\n00:00:01.000 --> 00:00:02.000\n".to_vec();
24 vtt_doc.extend_from_slice(data);
25 if let Ok(track) = webvtt::parse(&vtt_doc) {
26 for cue in &track.cues {
27 let _ = plain_text(&cue.segments);
28 }
29 }
30});