archer884 / harsh

Hashids implementation in Rust
Apache License 2.0
63 stars 4 forks source link

Harsh::decode panics when given input with invalid alphabet #12

Closed roosmaa closed 6 years ago

roosmaa commented 6 years ago

Here's the test case:

extern crate harsh;

fn main() {
    let h = harsh::HarshBuilder::new()
        .init().unwrap();
    h.decode("non-alphabet.characters=will|cause$panic");
    println!("No hello worlds :(");
}

And the output:

$ cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.00s
     Running `target/debug/harsh-test`
thread 'main' panicked at 'what a world, what a world!', libcore/option.rs:914:5
note: Run with `RUST_BACKTRACE=1` for a backtrace.

Expected the decode to return Option::None, not panic.

Harsh version 0.1.4