},
comment: {
optional: true,
- schema: datastore::COMMENT_SCHEMA,
+ schema: SINGLE_LINE_COMMENT_SCHEMA,
},
path: {
schema: datastore::DIR_NAME_SCHEMA,
bail!("datastore '{}' already exists.", name);
}
- if let Some(ref comment) = datastore.comment {
- if comment.find(|c: char| c.is_control()).is_some() {
- bail!("comment must not contain control characters!");
- }
- }
-
let path: PathBuf = datastore.path.clone().into();
let backup_user = crate::backup::backup_user()?;
},
comment: {
optional: true,
- schema: remotes::COMMENT_SCHEMA,
+ schema: SINGLE_LINE_COMMENT_SCHEMA,
},
host: {
schema: remotes::REMOTE_HOST_SCHEMA,
/// names this way. This is not only useful for filenames, but for
/// any identifier command line tools work with.
pub PROXMOX_SAFE_ID_REGEX = r"^[A-Za-z0-9_][A-Za-z0-9._\-]*";
+
+ pub SINGLE_LINE_COMMENT_REGEX = r"^[[:^cntrl:]]*$";
}
pub const SYSTEMD_DATETIME_FORMAT: ApiStringFormat =
pub const PROXMOX_SAFE_ID_FORMAT: ApiStringFormat =
ApiStringFormat::Pattern(&PROXMOX_SAFE_ID_REGEX);
+pub const SINGLE_LINE_COMMENT_FORMAT: ApiStringFormat =
+ ApiStringFormat::Pattern(&SINGLE_LINE_COMMENT_REGEX);
+
+
pub const PVE_CONFIG_DIGEST_SCHEMA: Schema = StringSchema::new(r#"\
Prevent changes if current configuration file has different SHA256 digest.
This can be used to prevent concurrent modifications.
.max_length(32)
.schema();
+pub const SINGLE_LINE_COMMENT_SCHEMA: Schema = StringSchema::new("Comment (single line).")
+ .format(&SINGLE_LINE_COMMENT_FORMAT)
+ .schema();
// Complex type definitions
// fixme: define better schemas
pub const DIR_NAME_SCHEMA: Schema = StringSchema::new("Directory name").schema();
-pub const COMMENT_SCHEMA: Schema = StringSchema::new("Datastore comment").schema();
#[api(
properties: {
comment: {
optional: true,
- schema: COMMENT_SCHEMA,
+ schema: SINGLE_LINE_COMMENT_SCHEMA,
},
path: {
schema: DIR_NAME_SCHEMA,
// fixme: define better schemas
-pub const COMMENT_SCHEMA: Schema = StringSchema::new("Comment").schema();
pub const REMOTE_HOST_SCHEMA: Schema = StringSchema::new("Host IP address or DNS name.").schema();
pub const REMOTE_USERID_SCHEMA: Schema = StringSchema::new("User ID").schema();
pub const REMOTE_PASSWORD_SCHEMA: Schema = StringSchema::new("Password or auth token.").schema();
properties: {
comment: {
optional: true,
- schema: COMMENT_SCHEMA,
+ schema: SINGLE_LINE_COMMENT_SCHEMA,
},
host: {
schema: REMOTE_HOST_SCHEMA,