From e5d5d1d4bdecfac326353d154c933e477c4e3eb8 Mon Sep 17 00:00:00 2001 From: Daniel Tang Date: Fri, 3 Mar 2023 05:28:11 -0500 Subject: [PATCH] Fix panic with invalid sync server URL with port (#2412) --- CONTRIBUTORS | 1 + rslib/src/backend/sync/mod.rs | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index b89c4be40..2c01107dc 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -112,6 +112,7 @@ Fabricio Duarte Mani Kaben Nanlohy Tobias Predel +Daniel Tang ******************** diff --git a/rslib/src/backend/sync/mod.rs b/rslib/src/backend/sync/mod.rs index e90a9229d..952190c42 100644 --- a/rslib/src/backend/sync/mod.rs +++ b/rslib/src/backend/sync/mod.rs @@ -86,6 +86,11 @@ impl TryFrom for SyncAuth { .endpoint .map(|v| { Url::try_from(v.as_str()) + // Without the next line, incomplete URLs like computer.local without the http:// + // are detected but URLs like computer.local:8000 are not. + // By calling join() now, these URLs are detected too and later code that + // uses and unwraps the result of join() doesn't panic + .and_then(|x| x.join("/")) .or_invalid("Invalid sync server specified. Please check the preferences.") }) .transpose()?,