From: Friedrich Weber <f.weber@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH widget-toolkit 3/3] window: edit: avoid shared object for extra request params
Date: Wed, 3 Apr 2024 11:10:10 +0200 [thread overview]
Message-ID: <20240403091010.11544-4-f.weber@proxmox.com> (raw)
In-Reply-To: <20240403091010.11544-1-f.weber@proxmox.com>
Currently, `Proxmox.window.Edit` initializes `extraRequestParams` to
an object that, if not overwritten, is shared between all instances of
subclasses. This bears the danger of modifying the shared object in a
subclass instead of overwriting it, which affects all edit windows of
the current session and can cause hard-to-catch UI bugs [1].
To avoid such bugs in the future, initialize `extraRequestParams` to
`undefined` instead, which forces subclasses to initialize their own
objects.
Note that bugs of the same kind can still happen if a subclass
initializes `extraRequestParams` to an empty shared object and
inadvertently modifies it, but at least they will be limited to that
particular subclass.
[1] https://lists.proxmox.com/pipermail/pve-devel/2024-March/062179.html
Signed-off-by: Friedrich Weber <f.weber@proxmox.com>
---
Notes:
With patch 2/3 applied, I think all occurrences of
`extraRequestParams` in PVE/PBS create their own object (PMG does not
seem to use `extraRequestParams`), so this patch should not break
anything, and if it does, it should be quite noticeable.
new in v2
src/window/Edit.js | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/window/Edit.js b/src/window/Edit.js
index d4a2b551..27cd8d01 100644
--- a/src/window/Edit.js
+++ b/src/window/Edit.js
@@ -9,7 +9,7 @@ Ext.define('Proxmox.window.Edit', {
// to submit extra params on load and submit, useful, e.g., if not all ID
// parameters are included in the URL
- extraRequestParams: {},
+ extraRequestParams: undefined,
resizable: false,
@@ -80,7 +80,9 @@ Ext.define('Proxmox.window.Edit', {
let me = this;
let values = {};
- Ext.apply(values, me.extraRequestParams);
+ if (me.extraRequestParams) {
+ Ext.apply(values, me.extraRequestParams);
+ }
let form = me.formPanel.getForm();
@@ -209,7 +211,7 @@ Ext.define('Proxmox.window.Edit', {
waitMsgTarget: me,
}, options);
- if (Object.keys(me.extraRequestParams).length > 0) {
+ if (me.extraRequestParams && Object.keys(me.extraRequestParams).length > 0) {
let params = newopts.params || {};
Ext.applyIf(params, me.extraRequestParams);
newopts.params = params;
--
2.39.2
next prev parent reply other threads:[~2024-04-03 9:11 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-03 9:10 [pve-devel] [PATCH manager/widget-toolkit 0/3] ui: avoid UI bugs due to shared " Friedrich Weber
2024-04-03 9:10 ` [pve-devel] [PATCH manager 1/3] ui: pool members: avoid setting request parameter for all edit windows Friedrich Weber
2024-04-03 9:10 ` [pve-devel] [PATCH manager 2/3] ui: pool members: avoid sharing object for extra request parameters Friedrich Weber
2024-04-03 9:10 ` Friedrich Weber [this message]
2024-04-04 8:22 ` [pve-devel] [PATCH widget-toolkit 3/3] window: edit: avoid shared object for extra request params Stefan Sterz
2024-04-04 9:01 ` Friedrich Weber
2024-04-04 9:23 ` Stefan Sterz
2024-04-04 10:10 ` Friedrich Weber
2024-04-04 10:54 ` Stefan Sterz
2024-04-04 11:04 ` Stefan Sterz
2024-04-04 10:59 ` Thomas Lamprecht
2024-04-04 11:28 ` Friedrich Weber
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=20240403091010.11544-4-f.weber@proxmox.com \
--to=f.weber@proxmox.com \
--cc=pve-devel@lists.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