napi-rs / node-rs

Node.js bindings ❤️ Rust crates
https://node-rs.dev
MIT License
1.12k stars 32 forks source link

Bug(jsonwebtoken): decode header panicking on result unwrap #799

Closed tada5hi closed 7 months ago

tada5hi commented 7 months ago

@Brooooooklyn the contributed code for decoding the jwt header causes a problem if the token is malformed (e.g. foo.bar.baz). I'm unfortunately not that familiar with rust and therefore don't know the best way to deal with it. I have tried locally with the "?" operator and "match" statements to solve the problem but without success. The result is that Rust panics:

thread '' panicked at packages\jsonwebtoken\src\decode.rs:9:10: called Result::unwrap() on an Err value: Error(Json(Error("expected value", line: 1, column: 1))) note: run with RUST_BACKTRACE=1 environment variable to display a backtrace