adracea / rsubs-lib

rust library for subtitle manipulation and conversion
https://crates.io/crates/rsubs-lib
MIT License
12 stars 7 forks source link

ParseIntError: panic parsing line number #48

Closed mrlogick closed 6 months ago

mrlogick commented 6 months ago

I have this main.rs:

fn main() {
    rsubs_lib::srt::parse_from_file("./subs.srt".to_string()).unwrap();
}

and this subs.srt:

1
00:00:37,138 --> 00:00:38,990
first line

2
00:00:39,090 --> 00:00:42,076
second line

then:

$ RUST_BACKTRACE=1 cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.01s
     Running `target/debug/test_rsub`
thread 'main' panicked at /home/mrlogick/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rsubs-lib-0.2.1/src/srt.rs:229:18:
Failed to parse line number: ParseIntError { kind: InvalidDigit }
stack backtrace:
   0: rust_begin_unwind
             at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library/std/src/panicking.rs:647:5
   1: core::panicking::panic_fmt
             at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library/core/src/panicking.rs:72:14
   2: core::result::unwrap_failed
             at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library/core/src/result.rs:1649:5
   3: core::result::Result<T,E>::expect
             at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library/core/src/result.rs:1030:23
   4: rsubs_lib::srt::parse
             at /home/pingu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rsubs-lib-0.2.1/src/srt.rs:225:35
   5: rsubs_lib::srt::parse_from_file
             at /home/pingu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rsubs-lib-0.2.1/src/srt.rs:251:8
   6: test_rsub::main
             at ./src/main.rs:2:5
   7: core::ops::function::FnOnce::call_once
             at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

I think it's a bug. It's been expected a string like "1", but it's trying to parse this instead: "\u{feff}1".