Skip to content

Commit

Permalink
Decode name/value
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed Jul 2, 2014
1 parent 923aca8 commit 724003d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/cookie.rs
Expand Up @@ -49,8 +49,8 @@ impl Cookie {
let mut pairs = s.trim().split(';');
let keyval = try_option!(pairs.next());
let (name, value) = try!(split(keyval));
c.name = name.to_string();
c.value = value.to_string();
c.name = url::decode_component(name);
c.value = url::decode_component(value);

for attr in pairs {
match attr.trim() {
Expand Down Expand Up @@ -150,4 +150,10 @@ mod tests {
"foo=bar; HttpOnly; Secure; Path=/foo; Domain=foo.com; \
Max-Age=4; wut=lol");
}

#[test]
fn odd_characters() {
let expected = Cookie::new("foo".to_string(), "b/r".to_string());
assert_eq!(Cookie::parse("foo=b%2Fr").unwrap(), expected);
}
}

0 comments on commit 724003d

Please sign in to comment.