From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 9D0F71FF140 for ; Fri, 27 Mar 2026 10:19:31 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id C502E37254; Fri, 27 Mar 2026 10:19:53 +0100 (CET) Message-ID: Date: Fri, 27 Mar 2026 10:19:09 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Beta Subject: Re: [PATCH v1 proxmox-backup] www: percent-encode maintenance mode message to allow commas To: Robert Obkircher , pbs-devel@lists.proxmox.com References: <20260326134854.176430-1-r.obkircher@proxmox.com> Content-Language: en-US From: Dominik Csapak In-Reply-To: <20260326134854.176430-1-r.obkircher@proxmox.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1774603109055 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.040 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: O4I3BA2JTWPT3CFWF7HOJGU34IGXKHZY X-Message-ID-Hash: O4I3BA2JTWPT3CFWF7HOJGU34IGXKHZY X-MailFrom: d.csapak@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Backup Server development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 > --- > 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}`; > }