diff options
author | Manish Goregaokar <manishsmail@gmail.com> | 2015-11-30 21:20:19 +0530 |
---|---|---|
committer | Manish Goregaokar <manishsmail@gmail.com> | 2015-11-30 22:01:33 +0530 |
commit | f8d906be103475d681900d1916fd8adb72c20d21 (patch) | |
tree | 4d2eeb0618de63608b48eb6413abef1eaf36c060 /components/net/cookie.rs | |
parent | b4213e6d8e2ab0dc03b5af9f9b1b2589b0e598a6 (diff) | |
download | servo-f8d906be103475d681900d1916fd8adb72c20d21.tar.gz servo-f8d906be103475d681900d1916fd8adb72c20d21.zip |
Make `path_matches` match the spec (fixes cookies)
Diffstat (limited to 'components/net/cookie.rs')
-rw-r--r-- | components/net/cookie.rs | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/components/net/cookie.rs b/components/net/cookie.rs index c0f6b1645f6..b496eb7256e 100644 --- a/components/net/cookie.rs +++ b/components/net/cookie.rs @@ -113,10 +113,21 @@ impl Cookie { // http://tools.ietf.org/html/rfc6265#section-5.1.4 pub fn path_match(request_path: &str, cookie_path: &str) -> bool { + // A request-path path-matches a given cookie-path if at least one of + // the following conditions holds: + + // The cookie-path and the request-path are identical. request_path == cookie_path || - ( request_path.starts_with(cookie_path) && - ( request_path.ends_with("/") || request_path[cookie_path.len()..].starts_with("/")) - ) + + (request_path.starts_with(cookie_path) && ( + // The cookie-path is a prefix of the request-path, and the last + // character of the cookie-path is %x2F ("/"). + cookie_path.ends_with("/") || + // The cookie-path is a prefix of the request-path, and the first + // character of the request-path that is not included in the cookie- + // path is a %x2F ("/") character. + request_path[cookie_path.len()..].starts_with("/") + )) } // http://tools.ietf.org/html/rfc6265#section-5.1.3 |