Update the third_party/rust/url library on the graphics branch in preparation for a merge from m-c with this update. r=me

MozReview-Commit-ID: 7RTeTt6jNWd
This commit is contained in:
Kartikaya Gupta 2016-12-19 13:29:03 -05:00
Родитель 3fb288b281
Коммит 96541c331b
11 изменённых файлов: 260 добавлений и 39 удалений

2
third_party/rust/url/.cargo-checksum.json поставляемый
Просмотреть файл

@ -1 +1 @@
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".gitignore":"e20a03cb660e0039506f8828204fd93815ebfe051ef62194f8dcf3fc8b7d0e5a",".travis.yml":"2a3033f9edf86bc829de486fc1e74fe0bbe3166ed99b0139754ea29772c19b06","Cargo.toml":"7ee4c235f4ccb6c6d2f3e836823b410bbd78c0be0fad0feb27e08828dc4fd0a9","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"20c7855c364d57ea4c97889a5e8d98470a9952dade37bd9248b9a54431670e5e","Makefile":"92b64915724e3b5fec95ec96c5af738bd219b80709e18bf8639d784bc3d9a600","README.md":"eb3f4694003f408cbe3c7f3e9fbbc71241defb940cc55a816981f0f0f144c8eb","UPGRADING.md":"fbcc2d39bdf17db0745793db6626fcd5c909dddd4ce13b27566cfabece22c368","appveyor.yml":"c78486dbfbe6ebbf3d808afb9a19f7ec18c4704ce451c6305f0716999b70a1a6","docs/.nojekyll":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","docs/404.html":"f61e6271c1ea1aa113b64b356e994595fa548f0433f89948d747503ad22195cd","docs/index.html":"f61e6271c1ea1aa113b64b356e994595fa548f0433f89948d747503ad22195cd","github.png":"b432fd855efe7c430fe6a57ccf83935c1996f03a7cdc8d6e1b34154b8c43f6ec","rust-url-todo":"1192cee7b6cedf2133d97dc6074b593a1d19b0ee13fff6f28d6329855044e575","src/encoding.rs":"7fb43e1c109bf9f2a80a05525082f90e79dba8e8056547571c49fba074406d39","src/form_urlencoded.rs":"172922f2c51eb8dae0182d70e5e0c2969f1b5b7aac026720ced9f84059465999","src/host.rs":"4c8b2b9953833edf4d4f0e8e398588c390751619149efdd431d8fb01df173f67","src/lib.rs":"7b3032836c56183183fe3c48f7740429276a35fbd0bda678dc26f9de9047efba","src/origin.rs":"d52010a280d363aed6832f7de5e52c1a62815302e59dcbc9cdc2574e2ac884b9","src/parser.rs":"8ca331ada66f309e91fcc375d8467c929b453979fe0ac5abe190eb8a32074db8","src/path_segments.rs":"0414985c441d0c0292ccc6f56a144b84728ae03382476e6cae1a766f8c333ef8","src/percent_encoding.rs":"44d3321eaa1c77715e9ea1421519289ca73612a31c3d6fce04ff489dfa7db3c5","src/quirks.rs":"3249d1a1f73dd29ec06d626ea2ea4d61e7b2a782543742a5bee422b2f3864b19","src/slicing.rs":"4e539886b23945a92094625f3e531a4bff40daa44240b5d19ee8577478c4f7fe","tests/data.rs":"d36f0ee509fb00524635a7968e336bb89674a82a4fcb06be189155e4b9d43db5","tests/setters_tests.json":"ebb439306ea748be6d0f93132cb59220c5805afd56357d6017f1eb1e4f0f80b3","tests/unit.rs":"69a55f1f4e554d8461035781a4a0a6c2dec5e1c461295850a627d7dc1dcc389b","tests/urltestdata.json":"e1931529969511f2144ee6491fa04c8466bce60836c1d6385fe842ceb963b45f"},"package":"48ccf7bd87a81b769cf84ad556e034541fb90e1cd6d4bc375c822ed9500cd9d7"} {"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".gitignore":"e20a03cb660e0039506f8828204fd93815ebfe051ef62194f8dcf3fc8b7d0e5a",".travis.yml":"2a3033f9edf86bc829de486fc1e74fe0bbe3166ed99b0139754ea29772c19b06","Cargo.toml":"c852af4c69ac79e8c960174967ab94c43f85bcf4bd6c373e402983fb5c121249","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"20c7855c364d57ea4c97889a5e8d98470a9952dade37bd9248b9a54431670e5e","Makefile":"92b64915724e3b5fec95ec96c5af738bd219b80709e18bf8639d784bc3d9a600","README.md":"eb3f4694003f408cbe3c7f3e9fbbc71241defb940cc55a816981f0f0f144c8eb","UPGRADING.md":"fbcc2d39bdf17db0745793db6626fcd5c909dddd4ce13b27566cfabece22c368","appveyor.yml":"c78486dbfbe6ebbf3d808afb9a19f7ec18c4704ce451c6305f0716999b70a1a6","docs/.nojekyll":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","docs/404.html":"f61e6271c1ea1aa113b64b356e994595fa548f0433f89948d747503ad22195cd","docs/index.html":"f61e6271c1ea1aa113b64b356e994595fa548f0433f89948d747503ad22195cd","github.png":"b432fd855efe7c430fe6a57ccf83935c1996f03a7cdc8d6e1b34154b8c43f6ec","src/encoding.rs":"7fb43e1c109bf9f2a80a05525082f90e79dba8e8056547571c49fba074406d39","src/form_urlencoded.rs":"172922f2c51eb8dae0182d70e5e0c2969f1b5b7aac026720ced9f84059465999","src/host.rs":"2225e135e86aa3d1c2d8aedb106cc10700958c94f721072ff62162dc7010b541","src/lib.rs":"83d02c956615925c8f96a904130af4f84bb9997fbdf8e5272723b609039a559a","src/origin.rs":"d52010a280d363aed6832f7de5e52c1a62815302e59dcbc9cdc2574e2ac884b9","src/parser.rs":"4ab643e63e6457bf2f108be8af1d0eed79ade3e0f66fb842d024d8345a9165d7","src/path_segments.rs":"0414985c441d0c0292ccc6f56a144b84728ae03382476e6cae1a766f8c333ef8","src/percent_encoding.rs":"44d3321eaa1c77715e9ea1421519289ca73612a31c3d6fce04ff489dfa7db3c5","src/quirks.rs":"3249d1a1f73dd29ec06d626ea2ea4d61e7b2a782543742a5bee422b2f3864b19","src/slicing.rs":"4e539886b23945a92094625f3e531a4bff40daa44240b5d19ee8577478c4f7fe","tests/data.rs":"d36f0ee509fb00524635a7968e336bb89674a82a4fcb06be189155e4b9d43db5","tests/setters_tests.json":"ebcbdb52e9a4b5a565f8806d52ebc610d46a34df883e10b0be080d026468ff73","tests/unit.rs":"eb320610de77c08d73909cf15ef53e0e032ca03a6b0851dec3f7cbc62b5ec572","tests/urltestdata.json":"a6926f9a39daecde55046fde050ae81a6783ba0a743a106413042bee93d3c106"},"package":"f024e241a55f5c88401595adc1d4af0c9649e91da82d0e190fe55950231ae575"}

2
third_party/rust/url/Cargo.toml поставляемый
Просмотреть файл

@ -1,7 +1,7 @@
[package] [package]
name = "url" name = "url"
version = "1.2.3" version = "1.2.4"
authors = ["The rust-url developers"] authors = ["The rust-url developers"]
description = "URL library for Rust, based on the WHATWG URL Standard" description = "URL library for Rust, based on the WHATWG URL Standard"

14
third_party/rust/url/rust-url-todo поставляемый
Просмотреть файл

@ -1,14 +0,0 @@
* standalone path parsing?
* Test setters
* Test trim C0/space
* Test remove tab & newline
#[test]
fn test_path_segments() {
let mut url = Url::parse("http://example.net").unwrap();
url.push_path_segment("foo").unwrap();
url.extend_path_segments(&["bar", "b/az"]).unwrap();
assert_eq!(url.as_str(), "http://example.net/foo");
}

1
third_party/rust/url/src/host.rs поставляемый
Просмотреть файл

@ -120,6 +120,7 @@ impl<S: AsRef<str>> fmt::Display for Host<S> {
/// This mostly exists because coherence rules dont allow us to implement /// This mostly exists because coherence rules dont allow us to implement
/// `ToSocketAddrs for (Host<S>, u16)`. /// `ToSocketAddrs for (Host<S>, u16)`.
#[derive(Clone)]
pub struct HostAndPort<S=String> { pub struct HostAndPort<S=String> {
pub host: Host<S>, pub host: Host<S>,
pub port: u16, pub port: u16,

196
third_party/rust/url/src/lib.rs поставляемый
Просмотреть файл

@ -228,12 +228,40 @@ impl<'a> ParseOptions<'a> {
impl Url { impl Url {
/// Parse an absolute URL from a string. /// Parse an absolute URL from a string.
///
/// # Examples
///
/// ```rust
/// use url::Url;
///
/// let url = Url::parse("https://example.net").unwrap();
/// ```
#[inline] #[inline]
pub fn parse(input: &str) -> Result<Url, ::ParseError> { pub fn parse(input: &str) -> Result<Url, ::ParseError> {
Url::options().parse(input) Url::options().parse(input)
} }
/// Parse a string as an URL, with this URL as the base URL. /// Parse a string as an URL, with this URL as the base URL.
///
/// # Examples
///
/// ```rust
/// use url::Url;
///
/// let url = Url::parse("https://example.net").unwrap();
/// let url = url.join("foo").unwrap();
/// assert_eq!(url.as_str(), "https://example.net/foo");
/// ```
///
/// Trailing slashes are not preserved:
///
/// ```rust
/// use url::Url;
///
/// let url = Url::parse("https://example.net/foo/").unwrap();
/// let url = url.join("bar").unwrap();
/// assert_eq!(url.as_str(), "https://example.net/foo/bar");
/// ```
#[inline] #[inline]
pub fn join(&self, input: &str) -> Result<Url, ::ParseError> { pub fn join(&self, input: &str) -> Result<Url, ::ParseError> {
Url::options().base_url(Some(self)).parse(input) Url::options().base_url(Some(self)).parse(input)
@ -251,6 +279,16 @@ impl Url {
/// Return the serialization of this URL. /// Return the serialization of this URL.
/// ///
/// This is fast since that serialization is already stored in the `Url` struct. /// This is fast since that serialization is already stored in the `Url` struct.
///
/// # Examples
///
/// ```rust
/// use url::Url;
///
/// let url_str = "https://example.net/";
/// let url = Url::parse(url_str).unwrap();
/// assert_eq!(url.as_str(), url_str);
/// ```
#[inline] #[inline]
pub fn as_str(&self) -> &str { pub fn as_str(&self) -> &str {
&self.serialization &self.serialization
@ -259,6 +297,16 @@ impl Url {
/// Return the serialization of this URL. /// Return the serialization of this URL.
/// ///
/// This consumes the `Url` and takes ownership of the `String` stored in it. /// This consumes the `Url` and takes ownership of the `String` stored in it.
///
/// # Examples
///
/// ```rust
/// use url::Url;
///
/// let url_str = "https://example.net/";
/// let url = Url::parse(url_str).unwrap();
/// assert_eq!(url.into_string(), url_str);
/// ```
#[inline] #[inline]
pub fn into_string(self) -> String { pub fn into_string(self) -> String {
self.serialization self.serialization
@ -445,6 +493,21 @@ impl Url {
/// ///
/// URLs that do *not* are either path-only like `unix:/run/foo.socket` /// URLs that do *not* are either path-only like `unix:/run/foo.socket`
/// or cannot-be-a-base like `data:text/plain,Stuff`. /// or cannot-be-a-base like `data:text/plain,Stuff`.
///
/// # Examples
///
/// ```
/// use url::Url;
///
/// let url = Url::parse("ftp://rms@example.com").unwrap();
/// assert!(url.has_authority());
///
/// let url = Url::parse("unix:/run/foo.socket").unwrap();
/// assert!(!url.has_authority());
///
/// let url = Url::parse("data:text/plain,Stuff").unwrap();
/// assert!(!url.has_authority());
/// ```
#[inline] #[inline]
pub fn has_authority(&self) -> bool { pub fn has_authority(&self) -> bool {
debug_assert!(self.byte_at(self.scheme_end) == b':'); debug_assert!(self.byte_at(self.scheme_end) == b':');
@ -456,9 +519,24 @@ impl Url {
/// ///
/// This is the case if the scheme and `:` delimiter are not followed by a `/` slash, /// This is the case if the scheme and `:` delimiter are not followed by a `/` slash,
/// as is typically the case of `data:` and `mailto:` URLs. /// as is typically the case of `data:` and `mailto:` URLs.
///
/// # Examples
///
/// ```
/// use url::Url;
///
/// let url = Url::parse("ftp://rms@example.com").unwrap();
/// assert!(!url.cannot_be_a_base());
///
/// let url = Url::parse("unix:/run/foo.socket").unwrap();
/// assert!(!url.cannot_be_a_base());
///
/// let url = Url::parse("data:text/plain,Stuff").unwrap();
/// assert!(url.cannot_be_a_base());
/// ```
#[inline] #[inline]
pub fn cannot_be_a_base(&self) -> bool { pub fn cannot_be_a_base(&self) -> bool {
self.byte_at(self.path_start) != b'/' !self.slice(self.path_start..).starts_with('/')
} }
/// Return the username for this URL (typically the empty string) /// Return the username for this URL (typically the empty string)
@ -517,6 +595,21 @@ impl Url {
} }
/// Equivalent to `url.host().is_some()`. /// Equivalent to `url.host().is_some()`.
///
/// # Examples
///
/// ```
/// use url::Url;
///
/// let url = Url::parse("ftp://rms@example.com").unwrap();
/// assert!(url.has_host());
///
/// let url = Url::parse("unix:/run/foo.socket").unwrap();
/// assert!(!url.has_host());
///
/// let url = Url::parse("data:text/plain,Stuff").unwrap();
/// assert!(!url.has_host());
/// ```
pub fn has_host(&self) -> bool { pub fn has_host(&self) -> bool {
!matches!(self.host, HostInternal::None) !matches!(self.host, HostInternal::None)
} }
@ -530,6 +623,24 @@ impl Url {
/// dont have a host. /// dont have a host.
/// ///
/// See also the `host` method. /// See also the `host` method.
///
/// # Examples
///
/// ```
/// use url::Url;
///
/// let url = Url::parse("https://127.0.0.1/index.html").unwrap();
/// assert_eq!(url.host_str(), Some("127.0.0.1"));
///
/// let url = Url::parse("ftp://rms@example.com").unwrap();
/// assert_eq!(url.host_str(), Some("example.com"));
///
/// let url = Url::parse("unix:/run/foo.socket").unwrap();
/// assert_eq!(url.host_str(), None);
///
/// let url = Url::parse("data:text/plain,Stuff").unwrap();
/// assert_eq!(url.host_str(), None);
/// ```
pub fn host_str(&self) -> Option<&str> { pub fn host_str(&self) -> Option<&str> {
if self.has_host() { if self.has_host() {
Some(self.slice(self.host_start..self.host_end)) Some(self.slice(self.host_start..self.host_end))
@ -545,6 +656,24 @@ impl Url {
/// dont have a host. /// dont have a host.
/// ///
/// See also the `host_str` method. /// See also the `host_str` method.
///
/// # Examples
///
/// ```
/// use url::Url;
///
/// let url = Url::parse("https://127.0.0.1/index.html").unwrap();
/// assert!(url.host().is_some());
///
/// let url = Url::parse("ftp://rms@example.com").unwrap();
/// assert!(url.host().is_some());
///
/// let url = Url::parse("unix:/run/foo.socket").unwrap();
/// assert!(url.host().is_none());
///
/// let url = Url::parse("data:text/plain,Stuff").unwrap();
/// assert!(url.host().is_none());
/// ```
pub fn host(&self) -> Option<Host<&str>> { pub fn host(&self) -> Option<Host<&str>> {
match self.host { match self.host {
HostInternal::None => None, HostInternal::None => None,
@ -555,6 +684,18 @@ impl Url {
} }
/// If this URL has a host and it is a domain name (not an IP address), return it. /// If this URL has a host and it is a domain name (not an IP address), return it.
///
/// # Examples
///
/// ```
/// use url::Url;
///
/// let url = Url::parse("https://127.0.0.1/").unwrap();
/// assert_eq!(url.domain(), None);
///
/// let url = Url::parse("https://example.com/").unwrap();
/// assert_eq!(url.domain(), Some("example.com"));
/// ```
pub fn domain(&self) -> Option<&str> { pub fn domain(&self) -> Option<&str> {
match self.host { match self.host {
HostInternal::Domain => Some(self.slice(self.host_start..self.host_end)), HostInternal::Domain => Some(self.slice(self.host_start..self.host_end)),
@ -563,6 +704,18 @@ impl Url {
} }
/// Return the port number for this URL, if any. /// Return the port number for this URL, if any.
///
/// # Examples
///
/// ```
/// use url::Url;
///
/// let url = Url::parse("https://example.com").unwrap();
/// assert_eq!(url.port(), None);
///
/// let url = Url::parse("ssh://example.com:22").unwrap();
/// assert_eq!(url.port(), Some(22));
/// ```
#[inline] #[inline]
pub fn port(&self) -> Option<u16> { pub fn port(&self) -> Option<u16> {
self.port self.port
@ -575,6 +728,21 @@ impl Url {
/// ///
/// For URLs in these schemes, this method always returns `Some(_)`. /// For URLs in these schemes, this method always returns `Some(_)`.
/// For other schemes, it is the same as `Url::port()`. /// For other schemes, it is the same as `Url::port()`.
///
/// # Examples
///
/// ```
/// use url::Url;
///
/// let url = Url::parse("foo://example.com").unwrap();
/// assert_eq!(url.port_or_known_default(), None);
///
/// let url = Url::parse("foo://example.com:1456").unwrap();
/// assert_eq!(url.port_or_known_default(), Some(1456));
///
/// let url = Url::parse("https://example.com").unwrap();
/// assert_eq!(url.port_or_known_default(), Some(443));
/// ```
#[inline] #[inline]
pub fn port_or_known_default(&self) -> Option<u16> { pub fn port_or_known_default(&self) -> Option<u16> {
self.port.or_else(|| parser::default_port(self.scheme())) self.port.or_else(|| parser::default_port(self.scheme()))
@ -851,6 +1019,20 @@ impl Url {
/// ///
/// If this URL is cannot-be-a-base, does not have a host, or has the `file` scheme; /// If this URL is cannot-be-a-base, does not have a host, or has the `file` scheme;
/// do nothing and return `Err`. /// do nothing and return `Err`.
///
/// # Examples
///
/// ```
/// use url::Url;
///
/// let mut url = Url::parse("ssh://example.net:2048/").unwrap();
///
/// url.set_port(Some(4096)).unwrap();
/// assert_eq!(url.as_str(), "ssh://example.net:4096/");
///
/// url.set_port(None).unwrap();
/// assert_eq!(url.as_str(), "ssh://example.net/");
/// ```
pub fn set_port(&mut self, mut port: Option<u16>) -> Result<(), ()> { pub fn set_port(&mut self, mut port: Option<u16>) -> Result<(), ()> {
if !self.has_host() || self.scheme() == "file" { if !self.has_host() || self.scheme() == "file" {
return Err(()) return Err(())
@ -905,12 +1087,18 @@ impl Url {
} }
if let Some(host) = host { if let Some(host) = host {
if host == "" && SchemeType::from(self.scheme()).is_special() {
return Err(ParseError::EmptyHost);
}
self.set_host_internal(try!(Host::parse(host)), None) self.set_host_internal(try!(Host::parse(host)), None)
} else if self.has_host() { } else if self.has_host() {
if SchemeType::from(self.scheme()).is_special() {
return Err(ParseError::EmptyHost)
}
debug_assert!(self.byte_at(self.scheme_end) == b':'); debug_assert!(self.byte_at(self.scheme_end) == b':');
debug_assert!(self.byte_at(self.path_start) == b'/'); debug_assert!(self.byte_at(self.path_start) == b'/');
let new_path_start = self.scheme_end + 1; let new_path_start = self.scheme_end + 1;
self.serialization.drain(self.path_start as usize..new_path_start as usize); self.serialization.drain(new_path_start as usize..self.path_start as usize);
let offset = self.path_start - new_path_start; let offset = self.path_start - new_path_start;
self.path_start = new_path_start; self.path_start = new_path_start;
self.username_end = new_path_start; self.username_end = new_path_start;
@ -1335,7 +1523,7 @@ impl serde::Deserialize for Url {
} }
} }
#[cfg(unix)] #[cfg(any(unix, target_os = "redox"))]
fn path_to_file_url_segments(path: &Path, serialization: &mut String) -> Result<(), ()> { fn path_to_file_url_segments(path: &Path, serialization: &mut String) -> Result<(), ()> {
use std::os::unix::prelude::OsStrExt; use std::os::unix::prelude::OsStrExt;
if !path.is_absolute() { if !path.is_absolute() {
@ -1395,7 +1583,7 @@ fn path_to_file_url_segments_windows(path: &Path, serialization: &mut String) ->
Ok(()) Ok(())
} }
#[cfg(unix)] #[cfg(any(unix, target_os = "redox"))]
fn file_url_segments_to_pathbuf(segments: str::Split<char>) -> Result<PathBuf, ()> { fn file_url_segments_to_pathbuf(segments: str::Split<char>) -> Result<PathBuf, ()> {
use std::ffi::OsStr; use std::ffi::OsStr;
use std::os::unix::prelude::OsStrExt; use std::os::unix::prelude::OsStrExt;

5
third_party/rust/url/src/parser.rs поставляемый
Просмотреть файл

@ -1083,12 +1083,13 @@ impl<'a> Parser<'a> {
} }
pub fn parse_fragment(&mut self, mut input: Input) { pub fn parse_fragment(&mut self, mut input: Input) {
while let Some(c) = input.next() { while let Some((c, utf8_c)) = input.next_utf8() {
if c == '\0' { if c == '\0' {
self.syntax_violation("NULL characters are ignored in URL fragment identifiers") self.syntax_violation("NULL characters are ignored in URL fragment identifiers")
} else { } else {
self.check_url_code_point(c, &input); self.check_url_code_point(c, &input);
self.serialization.push(c); // No percent-encoding here. self.serialization.extend(utf8_percent_encode(utf8_c,
SIMPLE_ENCODE_SET));
} }
} }
} }

10
third_party/rust/url/tests/setters_tests.json поставляемый
Просмотреть файл

@ -1127,12 +1127,12 @@
} }
}, },
{ {
"comment": "No percent-encoding at all (!); nuls, tabs, and newlines are removed. Leading or training C0 controls and space are removed.", "comment": "Simple percent-encoding; nuls, tabs, and newlines are removed",
"href": "a:/", "href": "a:/",
"new_value": "\u0000\u0001\t\n\r\u001f !\u0000\u0001\t\n\r\u001f !\"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~\u007f\u0080\u0081Éé", "new_value": "\u0000\u0001\t\n\r\u001f !\u0000\u0001\t\n\r\u001f !\"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~\u007f\u0080\u0081Éé",
"expected": { "expected": {
"href": "a:/#!\u0001\u001f !\"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~\u007f\u0080\u0081Éé", "href": "a:/#!%01%1F !\"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~%7F%C2%80%C2%81%C3%89%C3%A9",
"hash": "#!\u0001\u001f !\"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~\u007f\u0080\u0081Éé" "hash": "#!%01%1F !\"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~%7F%C2%80%C2%81%C3%89%C3%A9"
} }
}, },
{ {
@ -1140,8 +1140,8 @@
"href": "http://example.net", "href": "http://example.net",
"new_value": "%c3%89té", "new_value": "%c3%89té",
"expected": { "expected": {
"href": "http://example.net/#%c3%89té", "href": "http://example.net/#%c3%89t%C3%A9",
"hash": "#%c3%89té" "hash": "#%c3%89t%C3%A9"
} }
} }
] ]

28
third_party/rust/url/tests/unit.rs поставляемый
Просмотреть файл

@ -15,6 +15,12 @@ use std::net::{Ipv4Addr, Ipv6Addr};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use url::{Host, Url, form_urlencoded}; use url::{Host, Url, form_urlencoded};
#[test]
fn size() {
use std::mem::size_of;
assert_eq!(size_of::<Url>(), size_of::<Option<Url>>());
}
macro_rules! assert_from_file_path { macro_rules! assert_from_file_path {
($path: expr) => { assert_from_file_path!($path, $path) }; ($path: expr) => { assert_from_file_path!($path, $path) };
($path: expr, $url_path: expr) => {{ ($path: expr, $url_path: expr) => {{
@ -196,6 +202,7 @@ fn host_serialization() {
fn test_idna() { fn test_idna() {
assert!("http://goșu.ro".parse::<Url>().is_ok()); assert!("http://goșu.ro".parse::<Url>().is_ok());
assert_eq!(Url::parse("http://☃.net/").unwrap().host(), Some(Host::Domain("xn--n3h.net"))); assert_eq!(Url::parse("http://☃.net/").unwrap().host(), Some(Host::Domain("xn--n3h.net")));
assert!("https://r2---sn-huoa-cvhl.googlevideo.com/crossdomain.xml".parse::<Url>().is_ok());
} }
#[test] #[test]
@ -274,6 +281,11 @@ fn issue_197() {
url.path_segments_mut().expect("path_segments_mut").pop_if_empty(); url.path_segments_mut().expect("path_segments_mut").pop_if_empty();
} }
#[test]
fn issue_241() {
Url::parse("mailto:").unwrap().cannot_be_a_base();
}
#[test] #[test]
/// https://github.com/servo/rust-url/issues/222 /// https://github.com/servo/rust-url/issues/222
fn append_trailing_slash() { fn append_trailing_slash() {
@ -305,3 +317,19 @@ fn append_empty_segment_then_mutate() {
url.assert_invariants(); url.assert_invariants();
assert_eq!(url.to_string(), "http://localhost:6767/foo/bar?a=b"); assert_eq!(url.to_string(), "http://localhost:6767/foo/bar?a=b");
} }
#[test]
/// https://github.com/servo/rust-url/issues/243
fn test_set_host() {
let mut url = Url::parse("https://example.net/hello").unwrap();
url.set_host(Some("foo.com")).unwrap();
assert_eq!(url.as_str(), "https://foo.com/hello");
assert!(url.set_host(None).is_err());
assert_eq!(url.as_str(), "https://foo.com/hello");
assert!(url.set_host(Some("")).is_err());
assert_eq!(url.as_str(), "https://foo.com/hello");
let mut url = Url::parse("foobar://example.net/hello").unwrap();
url.set_host(None).unwrap();
assert_eq!(url.as_str(), "foobar:/hello");
}

29
third_party/rust/url/tests/urltestdata.json поставляемый
Просмотреть файл

@ -1292,7 +1292,7 @@
{ {
"input": "#β", "input": "#β",
"base": "http://example.org/foo/bar", "base": "http://example.org/foo/bar",
"href": "http://example.org/foo/bar#β", "href": "http://example.org/foo/bar#%CE%B2",
"origin": "http://example.org", "origin": "http://example.org",
"protocol": "http:", "protocol": "http:",
"username": "", "username": "",
@ -1302,7 +1302,7 @@
"port": "", "port": "",
"pathname": "/foo/bar", "pathname": "/foo/bar",
"search": "", "search": "",
"hash": "#β" "hash": "#%CE%B2"
}, },
{ {
"input": "data:text/html,test#test", "input": "data:text/html,test#test",
@ -2161,7 +2161,7 @@
{ {
"input": "http://www.google.com/foo?bar=baz# »", "input": "http://www.google.com/foo?bar=baz# »",
"base": "about:blank", "base": "about:blank",
"href": "http://www.google.com/foo?bar=baz# »", "href": "http://www.google.com/foo?bar=baz# %C2%BB",
"origin": "http://www.google.com", "origin": "http://www.google.com",
"protocol": "http:", "protocol": "http:",
"username": "", "username": "",
@ -2171,12 +2171,12 @@
"port": "", "port": "",
"pathname": "/foo", "pathname": "/foo",
"search": "?bar=baz", "search": "?bar=baz",
"hash": "# »" "hash": "# %C2%BB"
}, },
{ {
"input": "data:test# »", "input": "data:test# »",
"base": "about:blank", "base": "about:blank",
"href": "data:test# »", "href": "data:test# %C2%BB",
"origin": "null", "origin": "null",
"protocol": "data:", "protocol": "data:",
"username": "", "username": "",
@ -2186,7 +2186,7 @@
"port": "", "port": "",
"pathname": "test", "pathname": "test",
"search": "", "search": "",
"hash": "# »" "hash": "# %C2%BB"
}, },
{ {
"input": "http://[www.google.com]/", "input": "http://[www.google.com]/",
@ -4356,5 +4356,22 @@
"search": "", "search": "",
"searchParams": "", "searchParams": "",
"hash": "" "hash": ""
},
"# Percent encoding of fragments",
{
"input": "http://foo.bar/baz?qux#foo\bbar",
"base": "about:blank",
"href": "http://foo.bar/baz?qux#foo%08bar",
"origin": "http://foo.bar",
"protocol": "http:",
"username": "",
"password": "",
"host": "foo.bar",
"hostname": "foo.bar",
"port": "",
"pathname": "/baz",
"search": "?qux",
"searchParams": "",
"hash": "#foo%08bar"
} }
] ]

6
toolkit/library/gtest/rust/Cargo.lock сгенерированный
Просмотреть файл

@ -307,7 +307,7 @@ version = "0.0.1"
dependencies = [ dependencies = [
"libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)",
"nsstring 0.1.0", "nsstring 0.1.0",
"url 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -447,7 +447,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "url" name = "url"
version = "1.2.3" version = "1.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"idna 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "idna 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -594,7 +594,7 @@ dependencies = [
"checksum unicode-bidi 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c1f7ceb96afdfeedee42bade65a0d585a6a0106f681b6749c8ff4daa8df30b3f" "checksum unicode-bidi 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c1f7ceb96afdfeedee42bade65a0d585a6a0106f681b6749c8ff4daa8df30b3f"
"checksum unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "26643a2f83bac55f1976fb716c10234485f9202dcd65cfbdf9da49867b271172" "checksum unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "26643a2f83bac55f1976fb716c10234485f9202dcd65cfbdf9da49867b271172"
"checksum unicode-xid 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "36dff09cafb4ec7c8cf0023eb0b686cb6ce65499116a12201c9e11840ca01beb" "checksum unicode-xid 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "36dff09cafb4ec7c8cf0023eb0b686cb6ce65499116a12201c9e11840ca01beb"
"checksum url 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "48ccf7bd87a81b769cf84ad556e034541fb90e1cd6d4bc375c822ed9500cd9d7" "checksum url 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f024e241a55f5c88401595adc1d4af0c9649e91da82d0e190fe55950231ae575"
"checksum user32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ef4711d107b21b410a3a974b1204d9accc8b10dad75d8324b5d755de1617d47" "checksum user32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ef4711d107b21b410a3a974b1204d9accc8b10dad75d8324b5d755de1617d47"
"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"

6
toolkit/library/rust/Cargo.lock сгенерированный
Просмотреть файл

@ -294,7 +294,7 @@ version = "0.0.1"
dependencies = [ dependencies = [
"libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)",
"nsstring 0.1.0", "nsstring 0.1.0",
"url 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -434,7 +434,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "url" name = "url"
version = "1.2.3" version = "1.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"idna 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "idna 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -581,7 +581,7 @@ dependencies = [
"checksum unicode-bidi 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c1f7ceb96afdfeedee42bade65a0d585a6a0106f681b6749c8ff4daa8df30b3f" "checksum unicode-bidi 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c1f7ceb96afdfeedee42bade65a0d585a6a0106f681b6749c8ff4daa8df30b3f"
"checksum unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "26643a2f83bac55f1976fb716c10234485f9202dcd65cfbdf9da49867b271172" "checksum unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "26643a2f83bac55f1976fb716c10234485f9202dcd65cfbdf9da49867b271172"
"checksum unicode-xid 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "36dff09cafb4ec7c8cf0023eb0b686cb6ce65499116a12201c9e11840ca01beb" "checksum unicode-xid 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "36dff09cafb4ec7c8cf0023eb0b686cb6ce65499116a12201c9e11840ca01beb"
"checksum url 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "48ccf7bd87a81b769cf84ad556e034541fb90e1cd6d4bc375c822ed9500cd9d7" "checksum url 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f024e241a55f5c88401595adc1d4af0c9649e91da82d0e190fe55950231ae575"
"checksum user32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ef4711d107b21b410a3a974b1204d9accc8b10dad75d8324b5d755de1617d47" "checksum user32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ef4711d107b21b410a3a974b1204d9accc8b10dad75d8324b5d755de1617d47"
"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"