hyperium / http

Rust HTTP types
Apache License 2.0
1.14k stars 284 forks source link

HeaderValue::from_str validate if string is visible ascii #524

Open xoac opened 2 years ago

xoac commented 2 years ago

close #519

The documentation say that valid ASCII is between (32..127) char. But function is_visible_ascii() check also for \t char what is coded as 9.

lilyball commented 2 years ago

Your PR description doesn't match the code. is_visible_ascii() actually allows for \t (even though it's not visible; I think the name here is wrong, it should be called is_valid_ascii instead). And what your PR does is restrict from_str to ASCII, which has nothing to do with \t.

xoac commented 2 years ago

I just matched implementation of from_static() that has exactly the same description for ASCII requirements as from_str and use the same function (is_visible_ascii) to check correctness but panic instead of returning error.

So the code should be correct if from_static() is correct.

lilyball commented 2 years ago

Note: I put a number of comments in the linked issue (https://github.com/hyperium/http/issues/519).