all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pdm-devel] [PATCH datacenter-manager v1] ui: remote wizard: fix "invalid uri character" when adding PBS remote
@ 2025-12-03 19:17 Max R. Carrara
  0 siblings, 0 replies; only message in thread
From: Max R. Carrara @ 2025-12-03 19:17 UTC (permalink / raw)
  To: pdm-devel

... by normalizing the hostname in the form context directly when the
user clicks on "Next" in the remote addition wizard.

This is necessary because the wizard takes the values for submission
directly from its form context.

This is somewhat easy to run into, e.g. if one copy-pastes the URL of
the PBS remote to add from another browser tab.

Signed-off-by: Max R. Carrara <m.carrara@proxmox.com>
---
Note: I'm not sure if there's a more elegant way to do this; if there
is, please let me know!

 ui/src/remotes/wizard_page_connect.rs | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/ui/src/remotes/wizard_page_connect.rs b/ui/src/remotes/wizard_page_connect.rs
index 789c522..fb04f60 100644
--- a/ui/src/remotes/wizard_page_connect.rs
+++ b/ui/src/remotes/wizard_page_connect.rs
@@ -45,7 +45,7 @@ pub struct ConnectParams {
 }
 
 async fn connect(form_ctx: FormContext, remote_type: RemoteType) -> Result<TlsProbeOutcome, Error> {
-    let hostname = normalize_hostname(form_ctx.read().get_field_text("hostname"));
+    let hostname = form_ctx.read().get_field_text("hostname");
     let fingerprint = get_fingerprint(&form_ctx);
     let pdm_client = crate::pdm_client();
     match remote_type {
@@ -170,6 +170,14 @@ impl Component for PdmWizardPageConnect {
                 self.loading = true;
                 props.info.page_lock(true);
 
+                let form_ctx = props.info.form_ctx.clone();
+
+                let mut guard = form_ctx.write();
+                let hostname = guard.get_field_text("hostname");
+                let new_hostname = normalize_hostname(hostname);
+                guard.set_field_value("hostname", new_hostname.into());
+                drop(guard);
+
                 self.scan_guard = Some(AsyncAbortGuard::spawn({
                     let link = ctx.link().clone();
                     let form_ctx = props.info.form_ctx.clone();
@@ -270,7 +278,7 @@ fn call_on_connect_change(props: &WizardPageConnect, certificate_info: Option<Ce
     if let Some(on_connect_change) = &props.on_connect_change {
         let fingerprint = get_fingerprint(&props.info.form_ctx);
         on_connect_change.emit(Some(ConnectParams {
-            hostname: normalize_hostname(props.info.form_ctx.read().get_field_text("hostname")),
+            hostname: props.info.form_ctx.read().get_field_text("hostname"),
             fingerprint: certificate_info
                 .and_then(|cert| cert.fingerprint)
                 .or(fingerprint),
-- 
2.47.3



_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-12-03 19:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-03 19:17 [pdm-devel] [PATCH datacenter-manager v1] ui: remote wizard: fix "invalid uri character" when adding PBS remote Max R. Carrara

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal