From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 3259960B08 for ; Thu, 17 Feb 2022 10:06:53 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 294561D074 for ; Thu, 17 Feb 2022 10:06:53 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id E4B701D066 for ; Thu, 17 Feb 2022 10:06:51 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 9D59C457A9 for ; Thu, 17 Feb 2022 09:58:04 +0100 (CET) Message-ID: Date: Thu, 17 Feb 2022 09:58:03 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Content-Language: en-US To: pbs-devel@lists.proxmox.com, Wolfgang Bumiller References: <20220216133917.101133-1-w.bumiller@proxmox.com> From: Fabian Ebner In-Reply-To: <20220216133917.101133-1-w.bumiller@proxmox.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.134 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment NICE_REPLY_A -0.001 Looks like a legit reply (A) SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [schema.rs, lib.rs] Subject: Re: [pbs-devel] [RFC proxmox] support quoted strings in property strings X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Feb 2022 09:06:53 -0000 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 > --- > 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, > +} > +