Fix incompatible future warnings by removing older crates (#1554)

This commit is contained in:
Firstyear 2023-04-20 15:49:51 +10:00 committed by GitHub
parent 155c93c931
commit db8cf8883b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 366 additions and 460 deletions

764
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -152,14 +152,11 @@ tracing-subscriber = { version = "^0.3.16", features = ["env-filter"] }
# tracing-forest = { path = "/Users/william/development/tracing-forest/tracing-forest" }
tracing-forest = { git = "https://github.com/QnnOkabayashi/tracing-forest.git", rev = "77daf8c8abf010b87d45ece2bf656983c6f8cecb" }
unicode-general-category = "0.6.0"
url = "^2.3.1"
urlencoding = "2.1.2"
users = "^0.11.0"
uuid = "^1.3.1"
validator = "^0.16.0"
wasm-bindgen = "^0.2.81"
wasm-bindgen-futures = "^0.4.30"
wasm-bindgen-test = "0.3.34"

View file

@ -45,7 +45,7 @@ openssl.workspace = true
r2d2.workspace = true
r2d2_sqlite.workspace = true
rand.workspace = true
regex.workspace = true
regex = { workspace = true, features = ["std", "perf", "perf-inline", "unicode", "unicode-gencat"] }
serde = { workspace = true, features = ["derive"] }
serde_cbor.workspace = true
serde_json.workspace = true
@ -63,11 +63,9 @@ nonempty = { workspace = true, features = ["serialize"] }
tracing = { workspace = true, features = ["attributes"] }
unicode-general-category.workspace = true
url = { workspace = true, features = ["serde"] }
urlencoding.workspace = true
uuid = { workspace = true, features = ["serde", "v4" ] }
validator = { workspace = true, features = ["phone"] }
webauthn-rs = { workspace = true, features = ["resident-key-support", "preview-features", "danger-credential-internals"] }
webauthn-rs-core.workspace = true
zxcvbn.workspace = true

View file

@ -76,6 +76,28 @@ lazy_static! {
#[allow(clippy::expect_used)]
Regex::new("[\n\r\t]").expect("Invalid singleline regex found")
};
/// Per https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address
/// this regex validates for valid emails.
pub static ref VALIDATE_EMAIL_RE: Regex = {
#[allow(clippy::expect_used)]
Regex::new(r"^[a-zA-Z0-9.!#$%&'*+=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$").expect("Invalid singleline regex found")
};
// Formerly checked with
/*
pub static ref ESCAPES_RE: Regex = {
#[allow(clippy::expect_used)]
Regex::new(r"\x1b\[([\x30-\x3f]*[\x20-\x2f]*[\x40-\x7e])")
.expect("Invalid escapes regex found")
};
*/
pub static ref UNICODE_CONTROL_RE: Regex = {
#[allow(clippy::expect_used)]
Regex::new(r"[[:cntrl:]]")
.expect("Invalid unicode control regex found")
};
}
#[derive(Debug, Clone, PartialOrd, Ord, Eq, PartialEq, Hash)]
@ -1253,7 +1275,7 @@ impl Value {
}
pub fn new_email_address_s(s: &str) -> Option<Self> {
if validator::validate_email(s) {
if VALIDATE_EMAIL_RE.is_match(s) {
Some(Value::EmailAddress(s.to_string(), false))
} else {
None
@ -1261,7 +1283,7 @@ impl Value {
}
pub fn new_email_address_primary_s(s: &str) -> Option<Self> {
if validator::validate_email(s) {
if VALIDATE_EMAIL_RE.is_match(s) {
Some(Value::EmailAddress(s.to_string(), true))
} else {
None
@ -1632,7 +1654,7 @@ impl Value {
// These have stricter validators so not needed.
Value::Nsuniqueid(s) => NSUNIQUEID_RE.is_match(s),
Value::DateTime(odt) => odt.offset() == time::UtcOffset::UTC,
Value::EmailAddress(mail, _) => validator::validate_email(mail.as_str()),
Value::EmailAddress(mail, _) => VALIDATE_EMAIL_RE.is_match(mail.as_str()),
Value::OauthScope(s) => OAUTHSCOPE_RE.is_match(s),
Value::OauthScopeMap(_, m) => m.iter().all(|s| OAUTHSCOPE_RE.is_match(s)),
@ -1695,23 +1717,12 @@ impl Value {
pub(crate) fn validate_str_escapes(s: &str) -> bool {
// Look for and prevent certain types of string escapes and injections.
// Formerly checked with
/*
pub static ref ESCAPES_RE: Regex = {
#[allow(clippy::expect_used)]
Regex::new(r"\x1b\[([\x30-\x3f]*[\x20-\x2f]*[\x40-\x7e])")
.expect("Invalid escapes regex found")
};
*/
use unicode_general_category::{get_general_category, GeneralCategory};
s.chars().all(|c| match get_general_category(c) {
GeneralCategory::Control => {
if UNICODE_CONTROL_RE.is_match(s) {
warn!("value contains invalid unicode control character",);
false
} else {
true
}
_ => true,
})
}
}

View file

@ -6,7 +6,7 @@ use crate::be::dbvalue::DbValueAddressV1;
use crate::prelude::*;
use crate::repl::proto::{ReplAddressV1, ReplAttrV1};
use crate::schema::SchemaAttribute;
use crate::value::Address;
use crate::value::{Address, VALIDATE_EMAIL_RE};
use crate::valueset::{DbValueSetV2, ValueSet};
#[derive(Debug, Clone)]
@ -373,7 +373,7 @@ impl ValueSetT for ValueSetEmailAddress {
&& self
.set
.iter()
.all(|mail| validator::validate_email(mail.as_str()))
.all(|mail| VALIDATE_EMAIL_RE.is_match(mail.as_str()))
}
fn to_proto_string_clone_iter(&self) -> Box<dyn Iterator<Item = String> + '_> {