whisperfish / rust-phonenumber

Library for parsing, formatting and validating international phone numbers.
Apache License 2.0
163 stars 56 forks source link

[BUG] The library panicked over a specific combination of country and phone number #32

Closed dvazar closed 3 years ago

dvazar commented 3 years ago

Library version: phonenumber-0.3.1+8.12.9 How to reproduce:

use phonenumber::country::Id;

fn main() {
    if let Ok(pn) = phonenumber::parse(Some(Id::CH), "003-836-4618x3001") {
        phonenumber::is_valid(&pn);
    }

    ()
}

Stack backtrace:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ()', /home/adv/.cargo/registry/src/github.com-1ecc6299db9ec823/phonenumber-0.3.1+8.12.9/src/validator.rs:173:49
stack backtrace:
   0: rust_begin_unwind
             at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/std/src/panicking.rs:495:5
   1: core::panicking::panic_fmt
             at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/core/src/panicking.rs:92:14
   2: core::option::expect_none_failed
             at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/core/src/option.rs:1268:5
   3: core::result::Result<T,E>::unwrap
             at /home/adv/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/result.rs:973:23
   4: phonenumber::validator::source_for
             at /home/adv/.cargo/registry/src/github.com-1ecc6299db9ec823/phonenumber-0.3.1+8.12.9/src/validator.rs:173:21
   5: phonenumber::validator::is_valid_with
             at /home/adv/.cargo/registry/src/github.com-1ecc6299db9ec823/phonenumber-0.3.1+8.12.9/src/validator.rs:112:33
   6: phonenumber::validator::is_valid
             at /home/adv/.cargo/registry/src/github.com-1ecc6299db9ec823/phonenumber-0.3.1+8.12.9/src/validator.rs:105:2
   7: pyphonenumber::main
             at ./src/main.rs:6:9
   8: core::ops::function::FnOnce::call_once
             at /home/adv/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.