From 55179d6ab2c602617d5c1391728d041223ae8358 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Tue, 13 Aug 2019 10:48:11 -0700 Subject: [PATCH] update dependencies --- CHANGES.md | 2 ++ Cargo.toml | 2 +- actix-files/CHANGES.md | 2 ++ actix-files/Cargo.toml | 2 +- actix-files/src/lib.rs | 4 +-- actix-http/CHANGES.md | 4 +++ actix-http/Cargo.toml | 4 +-- actix-http/src/cookie/mod.rs | 25 ++++++++++++++++--- actix-http/src/header/mod.rs | 47 +++++++++++++++++++++--------------- actix-http/src/test.rs | 8 +++--- awc/CHANGES.md | 9 +++++++ awc/Cargo.toml | 4 +-- awc/src/request.rs | 8 +++--- awc/src/test.rs | 8 +++--- awc/src/ws.rs | 7 +++--- test-server/CHANGES.md | 6 +++++ test-server/Cargo.toml | 2 +- 17 files changed, 97 insertions(+), 47 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index b3a0c86c..62eb0ef9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -12,6 +12,8 @@ * `Query` payload made `pub`. Allows user to pattern-match the payload. +* Update serde_urlencoded to "0.6.1" + ## [1.0.5] - 2019-07-18 diff --git a/Cargo.toml b/Cargo.toml index 9143f2fe..49889def 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -96,7 +96,7 @@ parking_lot = "0.9" regex = "1.0" serde = { version = "1.0", features=["derive"] } serde_json = "1.0" -serde_urlencoded = "0.5.3" +serde_urlencoded = "0.6.1" time = "0.1.42" url = { version="1.7", features=["query_encoding"] } diff --git a/actix-files/CHANGES.md b/actix-files/CHANGES.md index 8fdca4bc..49ecdbff 100644 --- a/actix-files/CHANGES.md +++ b/actix-files/CHANGES.md @@ -4,6 +4,8 @@ * Bump up `mime_guess` crate version to 2.0.1 +* Bump up `percent-encoding` crate version to 2.1 + ## [0.1.4] - 2019-07-20 * Allow to disable `Content-Disposition` header #686 diff --git a/actix-files/Cargo.toml b/actix-files/Cargo.toml index ee2121ff..a25ce17b 100644 --- a/actix-files/Cargo.toml +++ b/actix-files/Cargo.toml @@ -28,7 +28,7 @@ derive_more = "0.15.0" log = "0.4" mime = "0.3" mime_guess = "2.0.1" -percent-encoding = "1.0" +percent-encoding = "2.1" v_htmlescape = "0.4" [dev-dependencies] diff --git a/actix-files/src/lib.rs b/actix-files/src/lib.rs index 09642046..c99d3265 100644 --- a/actix-files/src/lib.rs +++ b/actix-files/src/lib.rs @@ -23,7 +23,7 @@ use futures::future::{ok, Either, FutureResult}; use futures::{Async, Future, Poll, Stream}; use mime; use mime_guess::from_ext; -use percent_encoding::{utf8_percent_encode, DEFAULT_ENCODE_SET}; +use percent_encoding::{utf8_percent_encode, CONTROLS}; use v_htmlescape::escape as escape_html_entity; mod error; @@ -144,7 +144,7 @@ impl Directory { // show file url as relative to static path macro_rules! encode_file_url { ($path:ident) => { - utf8_percent_encode(&$path.to_string_lossy(), DEFAULT_ENCODE_SET) + utf8_percent_encode(&$path.to_string_lossy(), CONTROLS) }; } diff --git a/actix-http/CHANGES.md b/actix-http/CHANGES.md index 8a8e8545..c8d1b2ae 100644 --- a/actix-http/CHANGES.md +++ b/actix-http/CHANGES.md @@ -6,6 +6,10 @@ * Dropped the `byteorder`-dependency in favor of `stdlib`-implementation +* Update percent-encoding to 2.1 + +* Update serde_urlencoded to 0.6.1 + ### Fixed * Fixed a panic in the HTTP2 handshake in client HTTP requests (#1031) diff --git a/actix-http/Cargo.toml b/actix-http/Cargo.toml index b64d5501..79d7117b 100644 --- a/actix-http/Cargo.toml +++ b/actix-http/Cargo.toml @@ -71,14 +71,14 @@ lazy_static = "1.0" language-tags = "0.2" log = "0.4" mime = "0.3" -percent-encoding = "1.0" +percent-encoding = "2.1" rand = "0.7" regex = "1.0" serde = "1.0" serde_json = "1.0" sha1 = "0.6" slab = "0.4" -serde_urlencoded = "0.5.5" +serde_urlencoded = "0.6.1" time = "0.1.42" tokio-tcp = "0.1.3" tokio-timer = "0.2.8" diff --git a/actix-http/src/cookie/mod.rs b/actix-http/src/cookie/mod.rs index f576a452..db821142 100644 --- a/actix-http/src/cookie/mod.rs +++ b/actix-http/src/cookie/mod.rs @@ -66,7 +66,7 @@ use std::fmt; use std::str::FromStr; use chrono::Duration; -use percent_encoding::{percent_encode, USERINFO_ENCODE_SET}; +use percent_encoding::{percent_encode, AsciiSet, CONTROLS}; use time::Tm; pub use self::builder::CookieBuilder; @@ -75,6 +75,25 @@ pub use self::jar::{CookieJar, Delta, Iter}; use self::parse::parse_cookie; pub use self::parse::ParseError; +/// https://url.spec.whatwg.org/#fragment-percent-encode-set +const FRAGMENT: &AsciiSet = &CONTROLS.add(b' ').add(b'"').add(b'<').add(b'>').add(b'`'); + +/// https://url.spec.whatwg.org/#path-percent-encode-set +const PATH: &AsciiSet = &FRAGMENT.add(b'#').add(b'?').add(b'{').add(b'}'); + +/// https://url.spec.whatwg.org/#userinfo-percent-encode-set +pub const USERINFO: &AsciiSet = &PATH + .add(b'/') + .add(b':') + .add(b';') + .add(b'=') + .add(b'@') + .add(b'[') + .add(b'\\') + .add(b']') + .add(b'^') + .add(b'|'); + #[derive(Debug, Clone)] enum CookieStr { /// An string derived from indexes (start, end). @@ -910,8 +929,8 @@ pub struct EncodedCookie<'a, 'c: 'a>(&'a Cookie<'c>); impl<'a, 'c: 'a> fmt::Display for EncodedCookie<'a, 'c> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { // Percent-encode the name and value. - let name = percent_encode(self.0.name().as_bytes(), USERINFO_ENCODE_SET); - let value = percent_encode(self.0.value().as_bytes(), USERINFO_ENCODE_SET); + let name = percent_encode(self.0.name().as_bytes(), USERINFO); + let value = percent_encode(self.0.value().as_bytes(), USERINFO); // Write out the name/value pair and the cookie's parameters. write!(f, "{}={}", name, value)?; diff --git a/actix-http/src/header/mod.rs b/actix-http/src/header/mod.rs index 62018347..37cf9450 100644 --- a/actix-http/src/header/mod.rs +++ b/actix-http/src/header/mod.rs @@ -6,6 +6,7 @@ use std::{fmt, str::FromStr}; use bytes::{Bytes, BytesMut}; use http::Error as HttpError; use mime::Mime; +use percent_encoding::{AsciiSet, CONTROLS}; pub use http::header::*; @@ -361,10 +362,8 @@ pub fn parse_extended_value( impl fmt::Display for ExtendedValue { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let encoded_value = percent_encoding::percent_encode( - &self.value[..], - self::percent_encoding_http::HTTP_VALUE, - ); + let encoded_value = + percent_encoding::percent_encode(&self.value[..], HTTP_VALUE); if let Some(ref lang) = self.language_tag { write!(f, "{}'{}'{}", self.charset, lang, encoded_value) } else { @@ -378,8 +377,7 @@ impl fmt::Display for ExtendedValue { /// /// [url]: https://tools.ietf.org/html/rfc5987#section-3.2 pub fn http_percent_encode(f: &mut fmt::Formatter, bytes: &[u8]) -> fmt::Result { - let encoded = - percent_encoding::percent_encode(bytes, self::percent_encoding_http::HTTP_VALUE); + let encoded = percent_encoding::percent_encode(bytes, HTTP_VALUE); fmt::Display::fmt(&encoded, f) } @@ -394,20 +392,29 @@ impl From for HeaderMap { } } -mod percent_encoding_http { - use percent_encoding::{self, define_encode_set}; - - // internal module because macro is hard-coded to make a public item - // but we don't want to public export this item - define_encode_set! { - // This encode set is used for HTTP header values and is defined at - // https://tools.ietf.org/html/rfc5987#section-3.2 - pub HTTP_VALUE = [percent_encoding::SIMPLE_ENCODE_SET] | { - ' ', '"', '%', '\'', '(', ')', '*', ',', '/', ':', ';', '<', '-', '>', '?', - '[', '\\', ']', '{', '}' - } - } -} +// This encode set is used for HTTP header values and is defined at +// https://tools.ietf.org/html/rfc5987#section-3.2 +pub(crate) const HTTP_VALUE: &AsciiSet = &CONTROLS + .add(b' ') + .add(b'"') + .add(b'%') + .add(b'\'') + .add(b'(') + .add(b')') + .add(b'*') + .add(b',') + .add(b'/') + .add(b':') + .add(b';') + .add(b'<') + .add(b'-') + .add(b'>') + .add(b'?') + .add(b'[') + .add(b'\\') + .add(b']') + .add(b'{') + .add(b'}'); #[cfg(test)] mod tests { diff --git a/actix-http/src/test.rs b/actix-http/src/test.rs index b4344a67..ce81a54d 100644 --- a/actix-http/src/test.rs +++ b/actix-http/src/test.rs @@ -9,9 +9,9 @@ use bytes::{Buf, Bytes, BytesMut}; use futures::{Async, Poll}; use http::header::{self, HeaderName, HeaderValue}; use http::{HttpTryFrom, Method, Uri, Version}; -use percent_encoding::{percent_encode, USERINFO_ENCODE_SET}; +use percent_encoding::percent_encode; -use crate::cookie::{Cookie, CookieJar}; +use crate::cookie::{Cookie, CookieJar, USERINFO}; use crate::header::HeaderMap; use crate::header::{Header, IntoHeaderValue}; use crate::payload::Payload; @@ -166,8 +166,8 @@ impl TestRequest { let mut cookie = String::new(); for c in inner.cookies.delta() { - let name = percent_encode(c.name().as_bytes(), USERINFO_ENCODE_SET); - let value = percent_encode(c.value().as_bytes(), USERINFO_ENCODE_SET); + let name = percent_encode(c.name().as_bytes(), USERINFO); + let value = percent_encode(c.value().as_bytes(), USERINFO); let _ = write!(&mut cookie, "; {}={}", name, value); } if !cookie.is_empty() { diff --git a/awc/CHANGES.md b/awc/CHANGES.md index 33d47fff..5e012def 100644 --- a/awc/CHANGES.md +++ b/awc/CHANGES.md @@ -1,5 +1,14 @@ # Changes +## [0.2.4] - 2019-xx-xx + +### Changed + +* Update percent-encoding to "2.1" + +* Update serde_urlencoded to "0.6.1" + + ## [0.2.3] - 2019-08-01 ### Added diff --git a/awc/Cargo.toml b/awc/Cargo.toml index 84baf4fb..42534cb1 100644 --- a/awc/Cargo.toml +++ b/awc/Cargo.toml @@ -51,11 +51,11 @@ derive_more = "0.15.0" futures = "0.1.25" log =" 0.4" mime = "0.3" -percent-encoding = "1.0" +percent-encoding = "2.1" rand = "0.7" serde = "1.0" serde_json = "1.0" -serde_urlencoded = "0.5.3" +serde_urlencoded = "0.6.1" tokio-timer = "0.2.8" openssl = { version="0.10", optional = true } rustls = { version = "0.15.2", optional = true } diff --git a/awc/src/request.rs b/awc/src/request.rs index 0e544589..43715785 100644 --- a/awc/src/request.rs +++ b/awc/src/request.rs @@ -7,13 +7,13 @@ use std::{fmt, net}; use bytes::{BufMut, Bytes, BytesMut}; use futures::future::{err, Either}; use futures::{Future, Stream}; -use percent_encoding::{percent_encode, USERINFO_ENCODE_SET}; +use percent_encoding::percent_encode; use serde::Serialize; use serde_json; use tokio_timer::Timeout; use actix_http::body::{Body, BodyStream}; -use actix_http::cookie::{Cookie, CookieJar}; +use actix_http::cookie::{Cookie, CookieJar, USERINFO}; use actix_http::encoding::Decoder; use actix_http::http::header::{self, ContentEncoding, Header, IntoHeaderValue}; use actix_http::http::{ @@ -399,8 +399,8 @@ impl ClientRequest { if let Some(ref mut jar) = self.cookies { let mut cookie = String::new(); for c in jar.delta() { - let name = percent_encode(c.name().as_bytes(), USERINFO_ENCODE_SET); - let value = percent_encode(c.value().as_bytes(), USERINFO_ENCODE_SET); + let name = percent_encode(c.name().as_bytes(), USERINFO); + let value = percent_encode(c.value().as_bytes(), USERINFO); let _ = write!(&mut cookie, "; {}={}", name, value); } self.head.headers.insert( diff --git a/awc/src/test.rs b/awc/src/test.rs index b852adb2..641ecaa8 100644 --- a/awc/src/test.rs +++ b/awc/src/test.rs @@ -1,12 +1,12 @@ //! Test helpers for actix http client to use during testing. use std::fmt::Write as FmtWrite; -use actix_http::cookie::{Cookie, CookieJar}; +use actix_http::cookie::{Cookie, CookieJar, USERINFO}; use actix_http::http::header::{self, Header, HeaderValue, IntoHeaderValue}; use actix_http::http::{HeaderName, HttpTryFrom, StatusCode, Version}; use actix_http::{h1, Payload, ResponseHead}; use bytes::Bytes; -use percent_encoding::{percent_encode, USERINFO_ENCODE_SET}; +use percent_encoding::percent_encode; use crate::ClientResponse; @@ -87,8 +87,8 @@ impl TestResponse { let mut cookie = String::new(); for c in self.cookies.delta() { - let name = percent_encode(c.name().as_bytes(), USERINFO_ENCODE_SET); - let value = percent_encode(c.value().as_bytes(), USERINFO_ENCODE_SET); + let name = percent_encode(c.name().as_bytes(), USERINFO); + let value = percent_encode(c.value().as_bytes(), USERINFO); let _ = write!(&mut cookie, "; {}={}", name, value); } if !cookie.is_empty() { diff --git a/awc/src/ws.rs b/awc/src/ws.rs index 27f454ed..72c9a38b 100644 --- a/awc/src/ws.rs +++ b/awc/src/ws.rs @@ -8,9 +8,10 @@ use actix_codec::Framed; use actix_http::cookie::{Cookie, CookieJar}; use actix_http::{ws, Payload, RequestHead}; use futures::future::{err, Either, Future}; -use percent_encoding::{percent_encode, USERINFO_ENCODE_SET}; +use percent_encoding::percent_encode; use tokio_timer::Timeout; +use actix_http::cookie::USERINFO; pub use actix_http::ws::{CloseCode, CloseReason, Codec, Frame, Message}; use crate::connect::BoxedSocket; @@ -236,8 +237,8 @@ impl WebsocketsRequest { if let Some(ref mut jar) = self.cookies { let mut cookie = String::new(); for c in jar.delta() { - let name = percent_encode(c.name().as_bytes(), USERINFO_ENCODE_SET); - let value = percent_encode(c.value().as_bytes(), USERINFO_ENCODE_SET); + let name = percent_encode(c.name().as_bytes(), USERINFO); + let value = percent_encode(c.value().as_bytes(), USERINFO); let _ = write!(&mut cookie, "; {}={}", name, value); } self.head.headers.insert( diff --git a/test-server/CHANGES.md b/test-server/CHANGES.md index 33314421..c3fe5b28 100644 --- a/test-server/CHANGES.md +++ b/test-server/CHANGES.md @@ -1,5 +1,11 @@ # Changes + +### Changed + +* Update serde_urlencoded to "0.6.1" + + ## [0.2.4] - 2019-07-18 * Update actix-server to 0.6 diff --git a/test-server/Cargo.toml b/test-server/Cargo.toml index fff96893..22809c06 100644 --- a/test-server/Cargo.toml +++ b/test-server/Cargo.toml @@ -49,7 +49,7 @@ serde = "1.0" serde_json = "1.0" sha1 = "0.6" slab = "0.4" -serde_urlencoded = "0.5.3" +serde_urlencoded = "0.6.1" time = "0.1" tokio-tcp = "0.1" tokio-timer = "0.2"