mirror of
https://github.com/fafhrd91/actix-web
synced 2025-06-25 14:49:20 +02:00
update dependencies
This commit is contained in:
@ -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)?;
|
||||
|
@ -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<http::HeaderMap> 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 {
|
||||
|
@ -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() {
|
||||
|
Reference in New Issue
Block a user