public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: Robert Obkircher <r.obkircher@proxmox.com>, pbs-devel@lists.proxmox.com
Subject: Re: [PATCH v1 proxmox-backup] www: percent-encode maintenance mode message to allow commas
Date: Fri, 27 Mar 2026 10:19:09 +0100	[thread overview]
Message-ID: <b588ba09-e4b4-40e0-bdb2-4c98fbb4eafb@proxmox.com> (raw)
In-Reply-To: <20260326134854.176430-1-r.obkircher@proxmox.com>

just my 2 cents:

we should probably just adapt the frontend parser for propertystrings
to also handle quoting. one idea was to use the rust crate + wasm
to do that (so we have a consistent parser across frontend+backed)
not sure it worth the effort to integrate wasm just for this single
parser

we can ofc extend the javascript parser to do that. I have some intial
js implementation of that lying around (from 2022, and only for
pve-manager though).

i could send that for pbs if it's desired

if neither is an option, we could ofc go with url encoding/decoding,
but the downside is that every (api)client has to do it themselves
(think pdm for example)


On 3/26/26 2:48 PM, Robert Obkircher wrote:
> Commas and equal signs caused problems because the maintenance mode
> message is stored in a property string.
> 
> With a comma and no quotes (e.g. 'a,b'), the backend failed to update
> datastore.cfg because 'read-only,message=a,b' couldn't be re-parsed.
> Adding a quote triggered the correct escape logic in the backend, but
> then the frontend displayed the mode and message incorrectly. It also
> cut off everything after the first equal sign and silently stripped
> backslashes.
> 
> Percent encoding was chosen because MaintenanceMode::check already
> decoded the message. Previously, this potentially caused the error
> message to differ from what was displayed in the web UI.
> 
> Signed-off-by: Robert Obkircher <r.obkircher@proxmox.com>
> ---
> I'm not sure if this is a good idea or if we should simply forbid those
> characters.
> 
> I also tried changing ElementSerializer::serialize_str to quote like
> ElementSerializeSeq, but that wouldn't be sufficient because the parser
> in the frontend would still split by comma and parse something like
> 'read-only,message="a,b"' as type 'b"' and message '"a'.
> 
>   www/Utils.js                     | 6 +++++-
>   www/window/MaintenanceOptions.js | 5 ++---
>   2 files changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/www/Utils.js b/www/Utils.js
> index fc9a5916..5e1ee0c6 100644
> --- a/www/Utils.js
> +++ b/www/Utils.js
> @@ -800,7 +800,11 @@ Ext.define('PBS.Utils', {
>               ([m, msg], pair) => {
>                   const [key, value] = pair.split('=');
>                   if (key === 'message') {
> -                    return [m, value.replace(/^"(.*)"$/, '$1').replace(/\\"/g, '"')];
> +                    try {
> +                        return [m, decodeURIComponent(value)];
> +                    } catch {
> +                        return [m, value];
> +                    }
>                   } else {
>                       return [value ?? key, msg];
>                   }
> diff --git a/www/window/MaintenanceOptions.js b/www/window/MaintenanceOptions.js
> index 9a735e5e..e9740843 100644
> --- a/www/window/MaintenanceOptions.js
> +++ b/www/window/MaintenanceOptions.js
> @@ -39,9 +39,8 @@ Ext.define('PBS.window.MaintenanceOptions', {
>               if (values.delete === 'maintenance-type') {
>                   values.delete = 'maintenance-mode';
>               } else if (values['maintenance-type']) {
> -                const message = (values['maintenance-msg'] ?? '')
> -                    .replaceAll('\\', '')
> -                    .replaceAll('"', '\\"');
> +                // property string values can't contain symbols like commas and equal signs
> +                const message = encodeURIComponent(values['maintenance-msg'] ?? '');
>                   const maybe_message = values['maintenance-msg'] ? `,message="${message}"` : '';
>                   values['maintenance-mode'] = `type=${values['maintenance-type']}${maybe_message}`;
>               }





  reply	other threads:[~2026-03-27  9:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-26 13:46 Robert Obkircher
2026-03-27  9:19 ` Dominik Csapak [this message]
2026-03-27 10:20   ` Robert Obkircher
2026-03-27 10:47     ` Dominik Csapak
2026-03-27 12:52       ` Robert Obkircher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b588ba09-e4b4-40e0-bdb2-4c98fbb4eafb@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    --cc=r.obkircher@proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal