[pdm-devel] [PATCH datacenter-manager v1] ui: remote wizard: fix "invalid uri character" when adding PBS remote

Max R. Carrara m.carrara at proxmox.com
Wed Dec 3 20:17:11 CET 2025


... 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 at 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





More information about the pdm-devel mailing list