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 3E2581FF140 for ; Fri, 27 Mar 2026 13:53:03 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 16F979B76; Fri, 27 Mar 2026 13:53:26 +0100 (CET) Message-ID: <50fe57b6-d7d4-40a1-9e17-bc904ea30cdd@proxmox.com> Date: Fri, 27 Mar 2026 13:52:49 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 proxmox-backup] www: percent-encode maintenance mode message to allow commas To: Dominik Csapak , pbs-devel@lists.proxmox.com References: <20260326134854.176430-1-r.obkircher@proxmox.com> <532d265a-e59b-4283-80f6-8f5d01f0b826@proxmox.com> <18ff0c89-27bd-4ae6-8906-7456fb5aaf5c@proxmox.com> Content-Language: en-US, de-AT From: Robert Obkircher In-Reply-To: <18ff0c89-27bd-4ae6-8906-7456fb5aaf5c@proxmox.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1774615919509 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.065 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: JLCFTLJFOYHG3Z7LDTTX7XC5EZ7HOIFV X-Message-ID-Hash: JLCFTLJFOYHG3Z7LDTTX7XC5EZ7HOIFV X-MailFrom: r.obkircher@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: On 3/27/26 11:47, Dominik Csapak wrote: > > > On 3/27/26 11:19 AM, Robert Obkircher wrote: >> >> On 3/27/26 10:18, Dominik Csapak wrote: >>> 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 >> Just to be clear, rust currently doesn't quote [1] correctly either: >> >> |letmode=MaintenanceMode{ ty:MaintenanceType::ReadOnly, >> message:Some("abc,def".to_string()), }; >> lets=proxmox_schema::property_string::PropertyString::new(mode) >> .to_property_string() .unwrap(); >> assert_eq!(s,"read-only,message=abc,def"); >> letd=MaintenanceMode::deserialize(proxmox_schema::de::SchemaDeserializer::new( >> >> &s, &MaintenanceMode::API_SCHEMA, )) .expect("from >> to_property_string");// panics|  Oops, sorry about the formatting. >> >> >> This is documented here[1]. >> >> [1] >> https://git.proxmox.com/?p=proxmox.git;a=blob;f=proxmox-schema/src/schema.rs;h=47ee94dfa05a4bb38cb9f7772ffed72576408353;hb=HEAD#l1766 >> >> > > thanks for pointing that out, I thought we had proper quoting support > there (for some reason?) maybe only the parser and not the > serializer.... IMO we should fix that too?  It is mostly supported, the problem was just serialization of strings that contain commas. > >>> >>> 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). >> Note that parseMaintenanceMode is a custom parser that doesn't use >> parsePropertyString. >> > > sure but that has a big overlap so we could probably reuse > a proper parser here too...  It would be nice to re-use it via wasm but a JS version shouln't be too difficult. I also found parse_property_string in JSONSchema.pm, which would have to change as well. > >>> >>> 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}`; >>>>                } >>> >