aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-12-25 00:48:09 -0800
committerGitHub <noreply@github.com>2016-12-25 00:48:09 -0800
commitfcc3447dfc63571a51abe94ad27a21961d8ede4b (patch)
treecf4aaab380056d9b683e2ce670c9a637ab7f5c54
parentb5909f26cf4ca255d13bf31b3261e6c9df11a4a1 (diff)
parent3fce260f6e060468fce1b6e8e439c35ab714ec29 (diff)
downloadservo-fcc3447dfc63571a51abe94ad27a21961d8ede4b.tar.gz
servo-fcc3447dfc63571a51abe94ad27a21961d8ede4b.zip
Auto merge of #14722 - iamrohit7:check-secure-schemes, r=jdm
Check for wss schemes in Cookie::appropriate_for_url * Also adds a new helper, `ServoUrl::is_secure_scheme`. * Refactored `CookieStorage::push` and `CookieStorage::remove` to use the new helper. <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [x] These changes fix #14702 <!-- Either: --> - [X] These changes do not require tests because we can't test the changes yet. <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14722) <!-- Reviewable:end -->
-rw-r--r--components/net/cookie.rs2
-rw-r--r--components/net/cookie_storage.rs4
-rw-r--r--components/url/lib.rs5
3 files changed, 8 insertions, 3 deletions
diff --git a/components/net/cookie.rs b/components/net/cookie.rs
index b47246440ca..42a49a4ac0a 100644
--- a/components/net/cookie.rs
+++ b/components/net/cookie.rs
@@ -160,7 +160,7 @@ impl Cookie {
}
}
- if self.cookie.secure && url.scheme() != "https" {
+ if self.cookie.secure && !url.is_secure_scheme() {
return false;
}
if self.cookie.httponly && source == CookieSource::NonHTTP {
diff --git a/components/net/cookie_storage.rs b/components/net/cookie_storage.rs
index cf2779daa04..8d39334263c 100644
--- a/components/net/cookie_storage.rs
+++ b/components/net/cookie_storage.rs
@@ -38,7 +38,7 @@ impl CookieStorage {
let cookies = self.cookies_map.entry(domain).or_insert(vec![]);
// https://www.ietf.org/id/draft-ietf-httpbis-cookie-alone-01.txt Step 2
- if !cookie.cookie.secure && url.scheme() != "https" && url.scheme() != "wss" {
+ if !cookie.cookie.secure && !url.is_secure_scheme() {
let new_domain = cookie.cookie.domain.as_ref().unwrap();
let new_path = cookie.cookie.path.as_ref().unwrap();
@@ -85,7 +85,7 @@ impl CookieStorage {
// http://tools.ietf.org/html/rfc6265#section-5.3
pub fn push(&mut self, mut cookie: Cookie, url: &ServoUrl, source: CookieSource) {
// https://www.ietf.org/id/draft-ietf-httpbis-cookie-alone-01.txt Step 1
- if cookie.cookie.secure && url.scheme() != "https" && url.scheme() != "wss" {
+ if cookie.cookie.secure && !url.is_secure_scheme() {
return;
}
diff --git a/components/url/lib.rs b/components/url/lib.rs
index 415b2dd4ea6..43498444a54 100644
--- a/components/url/lib.rs
+++ b/components/url/lib.rs
@@ -79,6 +79,11 @@ impl ServoUrl {
self.0.scheme()
}
+ pub fn is_secure_scheme(&self) -> bool {
+ let scheme = self.scheme();
+ scheme == "https" || scheme == "wss"
+ }
+
pub fn as_str(&self) -> &str {
self.0.as_str()
}