diff --git a/Cargo.lock b/Cargo.lock index 4902d5d086d42..858b617d8d7cc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1593,7 +1593,7 @@ version = "0.0.1" dependencies = [ "nserror 0.1.0", "nsstring 0.1.0", - "url 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "xpcom 0.1.0", ] @@ -2078,7 +2078,7 @@ dependencies = [ "lmdb-rkv 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "ordered-float 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", - "url 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "uuid 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2842,7 +2842,7 @@ dependencies = [ [[package]] name = "url" -version = "1.7.0" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "idna 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2921,7 +2921,7 @@ dependencies = [ "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "url 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3386,7 +3386,7 @@ dependencies = [ "checksum unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "bf3a113775714a22dcb774d8ea3655c53a32debae63a063acc00a91cc586245f" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" -"checksum url 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f808aadd8cfec6ef90e4a14eb46f24511824d1ac596b9682703c87056c8678b7" +"checksum url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" "checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122" "checksum uuid 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e1436e58182935dcd9ce0add9ea0b558e8a87befe01c1a301e6020aeb0876363" "checksum vcpkg 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9e0a7d8bed3178a8fb112199d466eeca9ed09a14ba8ad67718179b4fd5487d0b" diff --git a/netwerk/base/mozurl/Cargo.toml b/netwerk/base/mozurl/Cargo.toml index 819fd2f509282..b6abd981a9290 100644 --- a/netwerk/base/mozurl/Cargo.toml +++ b/netwerk/base/mozurl/Cargo.toml @@ -4,7 +4,7 @@ version = "0.0.1" authors = ["Nika Layzell "] [dependencies] -url = "1.5.1" +url = "1.7.2" nsstring = { path = "../../../servo/support/gecko/nsstring" } nserror = { path = "../../../xpcom/rust/nserror" } xpcom = { path = "../../../xpcom/rust/xpcom" } diff --git a/third_party/rust/url/.cargo-checksum.json b/third_party/rust/url/.cargo-checksum.json index 191a3ced790d0..1264581aa5d0e 100644 --- a/third_party/rust/url/.cargo-checksum.json +++ b/third_party/rust/url/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"0c9e7c23f4216471a535938d0babb4c30595c0ed747ef208da3f042027a3b55b","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"20c7855c364d57ea4c97889a5e8d98470a9952dade37bd9248b9a54431670e5e","README.md":"eb3f4694003f408cbe3c7f3e9fbbc71241defb940cc55a816981f0f0f144c8eb","UPGRADING.md":"fbcc2d39bdf17db0745793db6626fcd5c909dddd4ce13b27566cfabece22c368","appveyor.yml":"c78486dbfbe6ebbf3d808afb9a19f7ec18c4704ce451c6305f0716999b70a1a6","docs/404.html":"f61e6271c1ea1aa113b64b356e994595fa548f0433f89948d747503ad22195cd","docs/index.html":"f61e6271c1ea1aa113b64b356e994595fa548f0433f89948d747503ad22195cd","src/encoding.rs":"f3e109ca8ec5a9130da50cdfb3003530aedb6dd5a440f0790d76b71f6981119c","src/form_urlencoded.rs":"320418526c4564a4469581d426e7467bcefe504eecd098e1eb90a2663a75fd80","src/host.rs":"66a2c0c77a8add2da16bc690fbc82b130cf1367ac655fc36990a214e193a4d6c","src/lib.rs":"899d5741dc0da32cea327f11e10bd2f83722c854f946b7201aae4f6c12edc477","src/origin.rs":"6e4821eb9600a32ef54d05c8e1a7937f6d9b4dd1e3bda7f36c7988f6a2bef78b","src/parser.rs":"91882bcf1dc87c98b2849fe2cecfcbcfa9e478dd39e07b7c029269c98e613163","src/path_segments.rs":"7bd3142eaa568863ef44e2255c181239141f9eeee337f889b9ffaaeab4ca669d","src/quirks.rs":"6cf1697bad363532cbcc60917a9b126560ac3ab3e1a77da0abcf4f2a40c8233a","src/slicing.rs":"4e539886b23945a92094625f3e531a4bff40daa44240b5d19ee8577478c4f7fe","tests/data.rs":"e95a78cadbe156597938057b7048d0d0ac4d3568ca548c0658fbea88d71f2de1","tests/setters_tests.json":"08ddaa632ad19c81e83b904bfaa94bc971f26e2bdfcef27d2f93fd033ad57340","tests/unit.rs":"fb17881a57aab4d369cdbcbb4d062083fc2b80319187fe0040891d2830de22fe","tests/urltestdata.json":"1b0c7c727d8d7e79dfb0d0aa347ff05675ddb68bc4ead38f83fd8e89bc59cc32"},"package":"f808aadd8cfec6ef90e4a14eb46f24511824d1ac596b9682703c87056c8678b7"} \ No newline at end of file +{"files":{"Cargo.toml":"80d575ae6adad93cb0910b385b871e2d92d558078f58a3c8eafe95940d459f6b","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"20c7855c364d57ea4c97889a5e8d98470a9952dade37bd9248b9a54431670e5e","README.md":"eb3f4694003f408cbe3c7f3e9fbbc71241defb940cc55a816981f0f0f144c8eb","UPGRADING.md":"fbcc2d39bdf17db0745793db6626fcd5c909dddd4ce13b27566cfabece22c368","appveyor.yml":"c78486dbfbe6ebbf3d808afb9a19f7ec18c4704ce451c6305f0716999b70a1a6","benches/parse_url.rs":"821ecb051c3c6c40eb3b268ba7337b2988333627d0af0c8e1afc84734ffbbf2b","docs/404.html":"f61e6271c1ea1aa113b64b356e994595fa548f0433f89948d747503ad22195cd","docs/index.html":"f61e6271c1ea1aa113b64b356e994595fa548f0433f89948d747503ad22195cd","src/encoding.rs":"f3e109ca8ec5a9130da50cdfb3003530aedb6dd5a440f0790d76b71f6981119c","src/form_urlencoded.rs":"d8c35e92375cafcd7e12c4f0d5374bab62aa1f333629d55b007a9c3d5c3cb615","src/host.rs":"66a2c0c77a8add2da16bc690fbc82b130cf1367ac655fc36990a214e193a4d6c","src/lib.rs":"e09dcba401018169ee26764e1c2bccf0855a5d935707c2100fd8d8e77a1bbc91","src/origin.rs":"6e4821eb9600a32ef54d05c8e1a7937f6d9b4dd1e3bda7f36c7988f6a2bef78b","src/parser.rs":"76368cbe93308123c014a3502024cf97d97ca61dcfc7b6ecd710073867d6deca","src/path_segments.rs":"7bd3142eaa568863ef44e2255c181239141f9eeee337f889b9ffaaeab4ca669d","src/quirks.rs":"6cf1697bad363532cbcc60917a9b126560ac3ab3e1a77da0abcf4f2a40c8233a","src/slicing.rs":"4e539886b23945a92094625f3e531a4bff40daa44240b5d19ee8577478c4f7fe","tests/data.rs":"f2c1c6d1823e8d21aeeae31c786d7f4ef0d97352a896f8c5aeb03a41fedb9a48","tests/setters_tests.json":"08ddaa632ad19c81e83b904bfaa94bc971f26e2bdfcef27d2f93fd033ad57340","tests/unit.rs":"ead7185710ce06c8d68ea18700618477867ee355656eabcad26cfcfaaad361a0","tests/urltestdata.json":"1b0c7c727d8d7e79dfb0d0aa347ff05675ddb68bc4ead38f83fd8e89bc59cc32"},"package":"dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a"} \ No newline at end of file diff --git a/third_party/rust/url/Cargo.toml b/third_party/rust/url/Cargo.toml index 91933b2200386..ea661e0c6c6ae 100644 --- a/third_party/rust/url/Cargo.toml +++ b/third_party/rust/url/Cargo.toml @@ -12,7 +12,7 @@ [package] name = "url" -version = "1.7.0" +version = "1.7.2" authors = ["The rust-url developers"] description = "URL library for Rust, based on the WHATWG URL Standard" documentation = "https://docs.rs/url" @@ -33,6 +33,10 @@ name = "unit" [[test]] name = "data" harness = false + +[[bench]] +name = "parse_url" +harness = false [dependencies.encoding] version = "0.2" optional = true @@ -57,11 +61,14 @@ optional = true [dependencies.serde] version = ">=0.6.1, <0.9" optional = true +[dev-dependencies.bencher] +version = "0.1" + [dev-dependencies.rustc-serialize] version = "0.3" [dev-dependencies.rustc-test] -version = "0.2" +version = "0.3" [dev-dependencies.serde_json] version = ">=0.6.1, <0.9" diff --git a/third_party/rust/url/benches/parse_url.rs b/third_party/rust/url/benches/parse_url.rs new file mode 100644 index 0000000000000..d6ac3c402feee --- /dev/null +++ b/third_party/rust/url/benches/parse_url.rs @@ -0,0 +1,18 @@ +#[macro_use] +extern crate bencher; + +extern crate url; + +use bencher::{black_box, Bencher}; + +use url::Url; + +fn short(bench: &mut Bencher) { + let url = "https://example.com/bench"; + + bench.bytes = url.len() as u64; + bench.iter(|| black_box(url).parse::().unwrap()); +} + +benchmark_group!(benches, short); +benchmark_main!(benches); diff --git a/third_party/rust/url/src/form_urlencoded.rs b/third_party/rust/url/src/form_urlencoded.rs index 7ba8b4a300dea..f378c9a6cf841 100644 --- a/third_party/rust/url/src/form_urlencoded.rs +++ b/third_party/rust/url/src/form_urlencoded.rs @@ -257,8 +257,16 @@ impl<'a> Target for &'a mut String { // * `Serializer` keeps its target in a private field // * Unlike in other `Target` impls, `UrlQuery::finished` does not return `Self`. impl<'a> Target for ::UrlQuery<'a> { - fn as_mut_string(&mut self) -> &mut String { &mut self.url.serialization } - fn finish(self) -> &'a mut ::Url { self.url } + fn as_mut_string(&mut self) -> &mut String { + &mut self.url.as_mut().unwrap().serialization + } + + fn finish(mut self) -> &'a mut ::Url { + let url = self.url.take().unwrap(); + url.restore_already_parsed_fragment(self.fragment.take()); + url + } + type Finished = &'a mut ::Url; } diff --git a/third_party/rust/url/src/lib.rs b/third_party/rust/url/src/lib.rs index f24285fe1e52c..dbcd064051e71 100644 --- a/third_party/rust/url/src/lib.rs +++ b/third_party/rust/url/src/lib.rs @@ -112,6 +112,7 @@ assert_eq!(css_url.as_str(), "http://servo.github.io/rust-url/main.css"); #[cfg(feature="heapsize")] #[macro_use] extern crate heapsize; pub extern crate idna; +#[macro_use] pub extern crate percent_encoding; use encoding::EncodingOverride; @@ -1343,7 +1344,7 @@ impl Url { self.serialization.push('?'); } - let query = UrlQuery { url: self, fragment: fragment }; + let query = UrlQuery { url: Some(self), fragment: fragment }; form_urlencoded::Serializer::for_suffix(query, query_start + "?".len()) } @@ -2423,13 +2424,15 @@ fn io_error(reason: &str) -> io::Result { /// Implementation detail of `Url::query_pairs_mut`. Typically not used directly. #[derive(Debug)] pub struct UrlQuery<'a> { - url: &'a mut Url, + url: Option<&'a mut Url>, fragment: Option, } impl<'a> Drop for UrlQuery<'a> { fn drop(&mut self) { - self.url.restore_already_parsed_fragment(self.fragment.take()) + if let Some(url) = self.url.take() { + url.restore_already_parsed_fragment(self.fragment.take()) + } } } diff --git a/third_party/rust/url/src/parser.rs b/third_party/rust/url/src/parser.rs index 92b97afdd2b02..4f9cc524b495e 100644 --- a/third_party/rust/url/src/parser.rs +++ b/third_party/rust/url/src/parser.rs @@ -6,7 +6,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#[allow(unused_imports, deprecated)] use std::ascii::AsciiExt; + use std::error::Error; use std::fmt::{self, Formatter, Write}; use std::str; @@ -20,6 +22,12 @@ use percent_encoding::{ PATH_SEGMENT_ENCODE_SET }; +define_encode_set! { + // The backslash (\) character is treated as a path separator in special URLs + // so it needs to be additionally escaped in that case. + pub SPECIAL_PATH_SEGMENT_ENCODE_SET = [PATH_SEGMENT_ENCODE_SET] | {'\\'} +} + pub type ParseResult = Result; macro_rules! simple_enum_error { @@ -1009,8 +1017,13 @@ impl<'a> Parser<'a> { _ => { self.check_url_code_point(c, &input); if self.context == Context::PathSegmentSetter { - self.serialization.extend(utf8_percent_encode( - utf8_c, PATH_SEGMENT_ENCODE_SET)); + if scheme_type.is_special() { + self.serialization.extend(utf8_percent_encode( + utf8_c, SPECIAL_PATH_SEGMENT_ENCODE_SET)); + } else { + self.serialization.extend(utf8_percent_encode( + utf8_c, PATH_SEGMENT_ENCODE_SET)); + } } else { self.serialization.extend(utf8_percent_encode( utf8_c, DEFAULT_ENCODE_SET)); diff --git a/third_party/rust/url/tests/data.rs b/third_party/rust/url/tests/data.rs index 8885f6496ea10..e9203b1b05f09 100644 --- a/third_party/rust/url/tests/data.rs +++ b/third_party/rust/url/tests/data.rs @@ -9,7 +9,7 @@ //! Data-driven tests extern crate rustc_serialize; -extern crate test; +extern crate rustc_test as test; extern crate url; use rustc_serialize::json::{self, Json}; diff --git a/third_party/rust/url/tests/unit.rs b/third_party/rust/url/tests/unit.rs index 10bb86a9dbe54..62401c9437a70 100644 --- a/third_party/rust/url/tests/unit.rs +++ b/third_party/rust/url/tests/unit.rs @@ -109,6 +109,17 @@ fn new_directory_paths() { } } +#[test] +fn path_backslash_fun() { + let mut special_url = "http://foobar.com".parse::().unwrap(); + special_url.path_segments_mut().unwrap().push("foo\\bar"); + assert_eq!(special_url.as_str(), "http://foobar.com/foo%5Cbar"); + + let mut nonspecial_url = "thing://foobar.com".parse::().unwrap(); + nonspecial_url.path_segments_mut().unwrap().push("foo\\bar"); + assert_eq!(nonspecial_url.as_str(), "thing://foobar.com/foo\\bar"); +} + #[test] fn from_str() { assert!("http://testing.com/this".parse::().is_ok());