http
http copied to clipboard
HeaderValue::from_str validate if string is visible ascii
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
.
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
.
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.
Note: I put a number of comments in the linked issue (https://github.com/hyperium/http/issues/519).