hyperium / hyperium/http

HeaderValue::from_str does not validate that the string is valid ascii

Open
#519 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-headers E-easy S-bug
Dominant language
Rust
Stars
1.4k
Forks
378
Avg merge
1d 21h
Merged PRs (30d)
5

Description

The documentation of HeaderValue::from_str says that:

https://github.com/hyperium/http/blob/abe651273f4cf19cf9a247f376e9ece85becc722/src/header/value.rs#L101-L104

So I would expect this function to return an error when I pass it a non-ascii utf8 string which contains byte values in the 128-255 range. However the result is success.

Playground link

let x = http::header::HeaderValue::from_str("ñ");
panic!("{:?}", x);
thread 'main' panicked at 'Ok("\xc3\xb1")', src/main.rs:3:5

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the HeaderValue::from_str documentation and implementation in src/header/value.rs at the linked lines, then reproduce the non-ASCII example from the Rust Playground link. Done means the documented ASCII validation behavior is consistent with the observed result and the example no longer succeeds unexpectedly.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.