15 ms·
If you're parsing untrusted input, you should try to systemically avoid panics. Easier said than done, but I have started a small framework for protocol parsers
by briansmith 10y ago
If you're parsing untrusted input, you should try to systemically avoid panics. Easier said than done, but I have started a small framework for protocol parsers called untrusted.rs that helps: https://github.com/briansmith/untrusted https://github.com/briansmith/untrusted.
The main idea is that most panics (in parsers) are going to be caused by using the indexing operator on slices containing the untrusted input, so we wrap the input in a type that hides the slicing functionality, giving us only methods that return 'Result's.
nom is a much fancier thing which, IIUC, solves the same problems, and more: https://github.com/Geal/nom https://github.com/Geal/nom.