From 090decbe76e16c63fab14d9d6bffffaf1dd2779f Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Thu, 28 May 2020 21:02:54 +0200 Subject: [PATCH] BACKUP_REPO_URL_REGEX: move to api2::types and allow all valid data store names The repo URL consists of * optional userid * optional host * datastore name All three have defined regex or format, but none of that is used, so for example not all valid datastore names are accepted. Move definition of the regex over to api2::types where we can access all required regexes easily. Signed-off-by: Thomas Lamprecht --- src/api2/types.rs | 2 ++ src/client/backup_repo.rs | 6 +----- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/api2/types.rs b/src/api2/types.rs index cf6edfb6..2bc4132b 100644 --- a/src/api2/types.rs +++ b/src/api2/types.rs @@ -67,6 +67,8 @@ const_regex!{ pub PROXMOX_USER_ID_REGEX = concat!(r"^", USER_ID_REGEX_STR!(), r"$"); + pub BACKUP_REPO_URL_REGEX = concat!(r"^^(?:(?:(", USER_ID_REGEX_STR!(), ")@)?(", DNS_NAME!(), "|", IPRE!() ,"):)?(", PROXMOX_SAFE_ID_REGEX_STR!(), r")$"); + pub PROXMOX_GROUP_ID_REGEX = concat!(r"^", GROUP_NAME_REGEX_STR!(), r"$"); pub CERT_FINGERPRINT_SHA256_REGEX = r"^(?:[0-9a-fA-F][0-9a-fA-F])(?::[0-9a-fA-F][0-9a-fA-F]){31}$"; diff --git a/src/client/backup_repo.rs b/src/client/backup_repo.rs index bf3bb1fa..d02a1859 100644 --- a/src/client/backup_repo.rs +++ b/src/client/backup_repo.rs @@ -3,12 +3,8 @@ use std::fmt; use anyhow::{format_err, Error}; use proxmox::api::schema::*; -use proxmox::const_regex; -const_regex! { - /// Regular expression to parse repository URLs - pub BACKUP_REPO_URL_REGEX = r"^(?:(?:([\w@]+)@)?([\w\-_.]+):)?(\w+)$"; -} +use crate::api2::types::*; /// API schema format definition for repository URLs pub const BACKUP_REPO_URL: ApiStringFormat = ApiStringFormat::Pattern(&BACKUP_REPO_URL_REGEX);