[pbs-devel] [RFC proxmox] support quoted strings in property strings
Fabian Ebner
f.ebner at proxmox.com
Thu Feb 17 09:58:03 CET 2022
Am 16.02.22 um 14:39 schrieb Wolfgang Bumiller:
> This allows free form text to exist within property strings,
> quoted, like:
> key="A value with \"quotes, also commas",key2=value2
> or also:
> "the value for a default_key",key2=value2
>
> And drop ';' as a key=value separator since those are meant
> for arrays inside property strings...
>
Isn't that backwards-incompatible?
> Signed-off-by: Wolfgang Bumiller <w.bumiller at proxmox.com>
> ---
> This is mostly a reaction to Hannes' maintenance mode series.
> I think it would make more sense to improve our "property string
> specification" (as much as there is one :P) to support quoted strings.
> This way we can avoid the url encoding mess.
>
> We could also do this in PVE (which would be particularly useful if we
> want to allow adding notes to net/disk devices).
> AFAICT the only property strings containing string values which would
> in *theory* allow quotes in the beginning wouldn't work with them in
> *practice*, (eg. the 'path' in a container's mount point, or an 'mdev'
> in a VM's hostpci entry?)
>
> proxmox-schema/src/lib.rs | 2 +
> proxmox-schema/src/property_string.rs | 163 ++++++++++++++++++++++++++
> proxmox-schema/src/schema.rs | 25 ++--
> 3 files changed, 177 insertions(+), 13 deletions(-)
> create mode 100644 proxmox-schema/src/property_string.rs
>
> diff --git a/proxmox-schema/src/lib.rs b/proxmox-schema/src/lib.rs
> index 4e98443..13b0739 100644
> --- a/proxmox-schema/src/lib.rs
> +++ b/proxmox-schema/src/lib.rs
> @@ -19,6 +19,8 @@ pub use const_regex::ConstRegexPattern;
> pub mod de;
> pub mod format;
>
> +pub(crate) mod property_string;
> +
> mod schema;
> pub use schema::*;
>
> diff --git a/proxmox-schema/src/property_string.rs b/proxmox-schema/src/property_string.rs
> new file mode 100644
> index 0000000..a40c1ca
> --- /dev/null
> +++ b/proxmox-schema/src/property_string.rs
> @@ -0,0 +1,163 @@
> +//! Property string parsing
> +//! This may at some point also get a proper direkt `Serializer`/`Deserializer` for property
> +//! strings.
> +
> +use std::borrow::Cow;
> +use std::mem;
> +
> +use anyhow::{bail, format_err, Error};
> +
> +/// Iterate over the `key=value` pairs of a property string.
> +///
> +/// Note, that the `key` may be optional when the schema defines a "default" key.
Nit: But the iterator does not use the schema. Shouldn't the comment
here rather just describe the behavior of the iterator?
> +/// If the value does not require stripping backslash escapes it will be borrowed, otherwise an
> +/// owned `String` will be returned.
> +pub struct PropertyIterator<'a> {
> + data: &'a str,
> +}
> +
More information about the pbs-devel
mailing list