rust-italia / dgc

A parser and validator for the EU Digital Green Certificate (dgc) a.k.a. greenpass
https://github.com/rust-italia/dgc
MIT License
26 stars 11 forks source link

Remove possible panic on remove_prefix #15

Closed Rimpampa closed 2 years ago

Rimpampa commented 2 years ago

Accessing a str through a rage index may cause panic if the string contains multibyte chars. Another solution would be to do data.as_bytes()[0..4] != b"HC1:", because by considering them as raw bytes no panic can occur.