Update cookie + changes
This commit is contained in:
parent
e82c3fbea0
commit
3e3c30d7f1
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -294,9 +294,9 @@ checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1"
|
||||
|
||||
[[package]]
|
||||
name = "cookie"
|
||||
version = "0.17.0"
|
||||
version = "0.18.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7efb37c3e1ccb1ff97164ad95ac1606e8ccd35b3fa0a7d99a304c7f4a428cc24"
|
||||
checksum = "3cd91cf61412820176e137621345ee43b3f4423e589e7ae4e50d601d93e35ef8"
|
||||
dependencies = [
|
||||
"time",
|
||||
"version_check",
|
||||
|
@ -13,7 +13,7 @@ cached = { version = "0.46.1", features = ["async"] }
|
||||
clap = { version = "4.4.11", default-features = false, features = ["std", "env"] }
|
||||
regex = "1.10.2"
|
||||
serde = { version = "1.0.193", features = ["derive"] }
|
||||
cookie = "0.17.0"
|
||||
cookie = "0.18.0"
|
||||
futures-lite = "1.12.0"
|
||||
hyper = { version = "0.14.23", features = ["full"] }
|
||||
hyper-rustls = "0.24.0"
|
||||
|
@ -138,7 +138,7 @@ impl RequestExt for Request<Body> {
|
||||
.to_str()
|
||||
.unwrap_or_default()
|
||||
.split("; ")
|
||||
.map(|cookie| Cookie::parse(cookie).unwrap_or_else(|_| Cookie::named("")))
|
||||
.map(|cookie| Cookie::parse(cookie).unwrap_or_else(|_| Cookie::from("")))
|
||||
.collect()
|
||||
})
|
||||
}
|
||||
@ -155,7 +155,7 @@ impl ResponseExt for Response<Body> {
|
||||
.to_str()
|
||||
.unwrap_or_default()
|
||||
.split("; ")
|
||||
.map(|cookie| Cookie::parse(cookie).unwrap_or_else(|_| Cookie::named("")))
|
||||
.map(|cookie| Cookie::parse(cookie).unwrap_or_else(|_| Cookie::from("")))
|
||||
.collect()
|
||||
})
|
||||
}
|
||||
@ -167,7 +167,7 @@ impl ResponseExt for Response<Body> {
|
||||
}
|
||||
|
||||
fn remove_cookie(&mut self, name: String) {
|
||||
let mut cookie = Cookie::named(name);
|
||||
let mut cookie = Cookie::from(name);
|
||||
cookie.set_path("/");
|
||||
cookie.set_max_age(Duration::seconds(1));
|
||||
if let Ok(val) = header::HeaderValue::from_str(&cookie.to_string()) {
|
||||
|
@ -78,11 +78,11 @@ pub async fn set(req: Request<Body>) -> Result<Response<Body>, String> {
|
||||
for &name in &PREFS {
|
||||
match form.get(name) {
|
||||
Some(value) => response.insert_cookie(
|
||||
Cookie::build(name.to_owned(), value.clone())
|
||||
Cookie::build((name.to_owned(), value.clone()))
|
||||
.path("/")
|
||||
.http_only(true)
|
||||
.expires(OffsetDateTime::now_utc() + Duration::weeks(52))
|
||||
.finish(),
|
||||
.into(),
|
||||
),
|
||||
None => response.remove_cookie(name.to_string()),
|
||||
};
|
||||
@ -117,11 +117,11 @@ fn set_cookies_method(req: Request<Body>, remove_cookies: bool) -> Response<Body
|
||||
for name in [PREFS.to_vec(), vec!["subscriptions", "filters"]].concat() {
|
||||
match form.get(name) {
|
||||
Some(value) => response.insert_cookie(
|
||||
Cookie::build(name.to_owned(), value.clone())
|
||||
Cookie::build((name.to_owned(), value.clone()))
|
||||
.path("/")
|
||||
.http_only(true)
|
||||
.expires(OffsetDateTime::now_utc() + Duration::weeks(52))
|
||||
.finish(),
|
||||
.into(),
|
||||
),
|
||||
None => {
|
||||
if remove_cookies {
|
||||
|
@ -177,11 +177,11 @@ pub async fn add_quarantine_exception(req: Request<Body>) -> Result<Response<Bod
|
||||
let redir = param(&format!("?{}", req.uri().query().unwrap_or_default()), "redir").ok_or("Invalid URL")?;
|
||||
let mut response = redirect(redir);
|
||||
response.insert_cookie(
|
||||
Cookie::build(&format!("allow_quaran_{}", subreddit.to_lowercase()), "true")
|
||||
Cookie::build((&format!("allow_quaran_{}", subreddit.to_lowercase()), "true"))
|
||||
.path("/")
|
||||
.http_only(true)
|
||||
.expires(cookie::Expiration::Session)
|
||||
.finish(),
|
||||
.into(),
|
||||
);
|
||||
Ok(response)
|
||||
}
|
||||
@ -289,22 +289,22 @@ pub async fn subscriptions_filters(req: Request<Body>) -> Result<Response<Body>,
|
||||
response.remove_cookie("subscriptions".to_string());
|
||||
} else {
|
||||
response.insert_cookie(
|
||||
Cookie::build("subscriptions", sub_list.join("+"))
|
||||
Cookie::build(("subscriptions", sub_list.join("+")))
|
||||
.path("/")
|
||||
.http_only(true)
|
||||
.expires(OffsetDateTime::now_utc() + Duration::weeks(52))
|
||||
.finish(),
|
||||
.into(),
|
||||
);
|
||||
}
|
||||
if filters.is_empty() {
|
||||
response.remove_cookie("filters".to_string());
|
||||
} else {
|
||||
response.insert_cookie(
|
||||
Cookie::build("filters", filters.join("+"))
|
||||
Cookie::build(("filters", filters.join("+")))
|
||||
.path("/")
|
||||
.http_only(true)
|
||||
.expires(OffsetDateTime::now_utc() + Duration::weeks(52))
|
||||
.finish(),
|
||||
.into(),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -769,7 +769,7 @@ pub fn setting(req: &Request<Body>, name: &str) -> String {
|
||||
if let Some(default) = crate::config::get_setting(&format!("LIBREDDIT_DEFAULT_{}", name.to_uppercase())) {
|
||||
Cookie::new(name, default)
|
||||
} else {
|
||||
Cookie::named(name)
|
||||
Cookie::from(name)
|
||||
}
|
||||
})
|
||||
.value()
|
||||
|
Loading…
Reference in New Issue
Block a user