http icon indicating copy to clipboard operation
http copied to clipboard

HeaderValue::from_str validate if string is visible ascii

Open xoac opened this issue 2 years ago • 3 comments

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.

xoac avatar Feb 17 '22 19:02 xoac

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.

lilyball avatar Feb 24 '22 23:02 lilyball

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.

xoac avatar Feb 24 '22 23:02 xoac

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

lilyball avatar Mar 06 '22 06:03 lilyball