[pbs-devel] [RFC proxmox] support quoted strings in property strings
Wolfgang Bumiller
w.bumiller at proxmox.com
Fri Feb 18 09:13:45 CET 2022
> On 02/18/2022 9:02 AM Fabian Ebner <f.ebner at proxmox.com> wrote:
>
>
> > +fn parse_quoted_string<'s>(data: &'_ mut &'s str) -> Result<Cow<'s, str>, Error> {
> > + let data_out = data;
> > + let data = data_out.as_bytes();
> > +
> > + if data[0] != b'"' {
> > + bail!("not a quoted string");
> > + }
> > +
> > + let mut i = 1;
> > + while i != data.len() {
> > + if data[i] == b'"' {
>
> What if a byte that's part of an UTF-8 character is equal to b'"', or
> can that not happen?
This cannot happen as then utf-8 wouldn't be ascii compatible.
In multibyte characters each byte has the high bit set and the first byte's
number of set high bits before the first zero bit tells you the length of the
sequence.
If that length were to cover a b'"' byte then the string was invalid to begin
with, which is not our fault.
More information about the pbs-devel
mailing list