From 4e05fc59998a90d60c7a79a4f42c5f6e0d00456a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 2 Nov 2023 21:03:52 +0200 Subject: [PATCH] sccparse: Fix leading spaces between the tab and caption data CCExtractor is creating files like this. Part-of: --- video/closedcaption/src/scc_parse/parser.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/video/closedcaption/src/scc_parse/parser.rs b/video/closedcaption/src/scc_parse/parser.rs index 603112d7..2de04052 100644 --- a/video/closedcaption/src/scc_parse/parser.rs +++ b/video/closedcaption/src/scc_parse/parser.rs @@ -111,6 +111,7 @@ fn scc_payload(s: &[u8]) -> IResult<&[u8], Vec> { /// Parser for a SCC caption line in the form `timecode\tpayload`. fn caption(s: &[u8]) -> IResult<&[u8], SccLine> { use nom::bytes::complete::tag; + use nom::character::complete::multispace0; use nom::combinator::map; use nom::error::context; use nom::sequence::tuple; @@ -118,8 +119,8 @@ fn caption(s: &[u8]) -> IResult<&[u8], SccLine> { context( "invalid SCC caption line", map( - tuple((timecode, tag("\t"), scc_payload, end_of_line)), - |(tc, _, value, _)| SccLine::Caption(tc, value), + tuple((timecode, tag("\t"), multispace0, scc_payload, end_of_line)), + |(tc, _, _, value, _)| SccLine::Caption(tc, value), ), )(s) }