Fix panic with invalid sync server URL with port (#2412)

This commit is contained in:
Daniel Tang 2023-03-03 05:28:11 -05:00 committed by GitHub
parent 097fecbded
commit e5d5d1d4bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View File

@ -112,6 +112,7 @@ Fabricio Duarte <fabricio.duarte.jr@gmail.com>
Mani <github.com/krmanik>
Kaben Nanlohy <kaben.nanlohy@gmail.com>
Tobias Predel <tobias.predel@gmail.com>
Daniel Tang <danielzgtg.opensource@gmail.com>
********************

View File

@ -86,6 +86,11 @@ impl TryFrom<pb::sync::SyncAuth> 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()?,