diff --git a/async-nats/src/client.rs b/async-nats/src/client.rs index 9791c246f..94a15edf9 100644 --- a/async-nats/src/client.rs +++ b/async-nats/src/client.rs @@ -30,7 +30,7 @@ use tokio::sync::{mpsc, oneshot}; use tracing::trace; static VERSION_RE: Lazy = - Lazy::new(|| Regex::new(r#"\Av?([0-9]+)\.?([0-9]+)?\.?([0-9]+)?"#).unwrap()); + Lazy::new(|| Regex::new(r"\Av?([0-9]+)\.?([0-9]+)?\.?([0-9]+)?").unwrap()); /// An error returned from the [`Client::publish`], [`Client::publish_with_headers`], /// [`Client::publish_with_reply`] or [`Client::publish_with_reply_and_headers`] functions. diff --git a/async-nats/src/jetstream/kv/mod.rs b/async-nats/src/jetstream/kv/mod.rs index cfb366565..f30db892d 100644 --- a/async-nats/src/jetstream/kv/mod.rs +++ b/async-nats/src/jetstream/kv/mod.rs @@ -67,8 +67,8 @@ fn kv_operation_from_message(message: &Message) -> Result } } -static VALID_BUCKET_RE: Lazy = Lazy::new(|| Regex::new(r#"\A[a-zA-Z0-9_-]+\z"#).unwrap()); -static VALID_KEY_RE: Lazy = Lazy::new(|| Regex::new(r#"\A[-/_=\.a-zA-Z0-9]+\z"#).unwrap()); +static VALID_BUCKET_RE: Lazy = Lazy::new(|| Regex::new(r"\A[a-zA-Z0-9_-]+\z").unwrap()); +static VALID_KEY_RE: Lazy = Lazy::new(|| Regex::new(r"\A[-/_=\.a-zA-Z0-9]+\z").unwrap()); pub(crate) const MAX_HISTORY: i64 = 64; const ALL_KEYS: &str = ">"; diff --git a/async-nats/src/jetstream/object_store/mod.rs b/async-nats/src/jetstream/object_store/mod.rs index 1f160e2dd..219bfce0b 100644 --- a/async-nats/src/jetstream/object_store/mod.rs +++ b/async-nats/src/jetstream/object_store/mod.rs @@ -42,8 +42,8 @@ const DEFAULT_CHUNK_SIZE: usize = 128 * 1024; const NATS_ROLLUP: &str = "Nats-Rollup"; const ROLLUP_SUBJECT: &str = "sub"; -static BUCKET_NAME_RE: Lazy = Lazy::new(|| Regex::new(r#"\A[a-zA-Z0-9_-]+\z"#).unwrap()); -static OBJECT_NAME_RE: Lazy = Lazy::new(|| Regex::new(r#"\A[-/_=\.a-zA-Z0-9]+\z"#).unwrap()); +static BUCKET_NAME_RE: Lazy = Lazy::new(|| Regex::new(r"\A[a-zA-Z0-9_-]+\z").unwrap()); +static OBJECT_NAME_RE: Lazy = Lazy::new(|| Regex::new(r"\A[-/_=\.a-zA-Z0-9]+\z").unwrap()); pub(crate) fn is_valid_bucket_name(bucket_name: &str) -> bool { BUCKET_NAME_RE.is_match(bucket_name) diff --git a/async-nats/src/service/mod.rs b/async-nats/src/service/mod.rs index 6cc604861..31f3b7431 100644 --- a/async-nats/src/service/mod.rs +++ b/async-nats/src/service/mod.rs @@ -48,11 +48,11 @@ pub const NATS_SERVICE_ERROR_CODE: &str = "Nats-Service-Error-Code"; // uses recommended semver validation expression from // https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string static SEMVER: Lazy = Lazy::new(|| { - Regex::new(r#"^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$"#) + Regex::new(r"^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$") .unwrap() }); // From ADR-33: Name can only have A-Z, a-z, 0-9, dash, underscore. -static NAME: Lazy = Lazy::new(|| Regex::new(r#"^[A-Za-z0-9\-_]+$"#).unwrap()); +static NAME: Lazy = Lazy::new(|| Regex::new(r"^[A-Za-z0-9\-_]+$").unwrap()); /// Represents state for all endpoints. #[derive(Debug, Clone, Serialize, Deserialize)]