Commas are not encoded correctly

0
closed
xr1s
xr1s
Posted 6 months ago

Commas are not encoded correctly #205

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=3ae5c661a52cfe034bdcd96d0634b7b0

println!("{}", cookie::Cookie::new("comma", ",").encoded());
// expected: comma=%2C
// actually: comma=,

According to https://httpwg.org/specs/rfc6265.html#sane-cookie and the Set-Cookie section above, %x00-%x20, %x22, %x2C, %x3B, %x5C, a.k.a. control characters, CRLFs, double quotes ", comma ,, semicolon ; and backslash \ need to be encoded.

Commas have special meaning as delimiters in HTTP headers, and its encoding is essential to my understanding.