Skip to content

Commit 205bcb1

Browse files
europaulrene
authored andcommitted
pillar: make URL joins use url.JoinPath
To prevent issues with missing or extra slashes when constructing URLs, replace string concatenation with url.JoinPath where applicable. Signed-off-by: Paul Gaiduk <paulg@zededa.com>
1 parent b8eaa04 commit 205bcb1

File tree

10 files changed

+78
-57
lines changed

10 files changed

+78
-57
lines changed

pkg/edgeview/src/network.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1075,7 +1075,12 @@ func getPeerCerts(subStr string) {
10751075
if basics.server != "" {
10761076
subStr = basics.server
10771077
if basics.proxy != "" {
1078-
subStr = subStr + "/" + basics.proxy
1078+
var err error
1079+
subStr, err = url.JoinPath(subStr, basics.proxy)
1080+
if err != nil {
1081+
fmt.Printf("error joining URL path: %v\n", err)
1082+
return
1083+
}
10791084
}
10801085
}
10811086
if subStr == "" {

pkg/pillar/cmd/downloader/syncop.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,15 +381,22 @@ func handleSyncOpResponse(ctx *downloaderContext, config types.DownloaderConfig,
381381

382382
// cloud storage interface functions/APIs
383383
func constructDatastoreContext(ctx *downloaderContext, configName string, NameIsURL bool, dst types.DatastoreConfig) (*types.DatastoreContext, error) {
384+
var err error
384385
dpath := dst.Dpath
385386
downloadURL := configName
386387
if !NameIsURL {
387388
downloadURL = dst.Fqdn
388389
if len(dpath) > 0 {
389-
downloadURL = downloadURL + "/" + dpath
390+
downloadURL, err = url.JoinPath(downloadURL, dpath)
391+
if err != nil {
392+
return nil, err
393+
}
390394
}
391395
if len(configName) > 0 {
392-
downloadURL = downloadURL + "/" + configName
396+
downloadURL, err = url.JoinPath(downloadURL, configName)
397+
if err != nil {
398+
return nil, err
399+
}
393400
}
394401
}
395402

pkg/pillar/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ require (
3333
github.com/k8snetworkplumbingwg/network-attachment-definition-client v1.5.0
3434
github.com/lf-edge/edge-containers v0.0.0-20251107072102-46bed3192170
3535
github.com/lf-edge/eve-api/go v0.0.0-20260114160322-5feda2767927
36-
github.com/lf-edge/eve-libs v0.0.0-20251217132956-95b6654d8655
36+
github.com/lf-edge/eve-libs v0.0.0-20260131092350-2a40e827255e
3737
github.com/lf-edge/eve/pkg/kube/cnirpc v0.0.0-20240315102754-0f6d1f182e0d
3838
github.com/lf-edge/go-qemu v0.0.0-20231121152149-4c467eda0c56
3939
github.com/linuxkit/linuxkit/src/cmd/linuxkit v0.0.0-20240507172735-6d37353ca1ee

pkg/pillar/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,8 +586,8 @@ github.com/lf-edge/edge-containers v0.0.0-20251107072102-46bed3192170 h1:bzTmpY7
586586
github.com/lf-edge/edge-containers v0.0.0-20251107072102-46bed3192170/go.mod h1:ta4JI0ank21dn8T1GFZDRLmxVZ6kWVe32cnhKkqMJJQ=
587587
github.com/lf-edge/eve-api/go v0.0.0-20260114160322-5feda2767927 h1:X+FcGf7U22d4SkCdb3kSwslaM4EENNMNFmlUZiBZSjE=
588588
github.com/lf-edge/eve-api/go v0.0.0-20260114160322-5feda2767927/go.mod h1:6HxNA/qKJVEqwpuOFkcQ0h3QyotvAs/cjHLC961FPOY=
589-
github.com/lf-edge/eve-libs v0.0.0-20251217132956-95b6654d8655 h1:3XWIDdz3uCUuDxrpHPlroWJVMI6Dbs17Wn+Bbi64TUs=
590-
github.com/lf-edge/eve-libs v0.0.0-20251217132956-95b6654d8655/go.mod h1:ltvACFoIkGSeuuK+4Gl5+or3dbIxG2np6K0PQYkk6hU=
589+
github.com/lf-edge/eve-libs v0.0.0-20260131092350-2a40e827255e h1:i0ic9x/u9PsdVvXvBCGUOJ9LXyw66zfJL9vy54di+UM=
590+
github.com/lf-edge/eve-libs v0.0.0-20260131092350-2a40e827255e/go.mod h1:ltvACFoIkGSeuuK+4Gl5+or3dbIxG2np6K0PQYkk6hU=
591591
github.com/lf-edge/eve/pkg/kube/cnirpc v0.0.0-20240315102754-0f6d1f182e0d h1:tUBb9M6u42LXwHAYHyh22wJeUUQlTpDkXwRXalpRqbo=
592592
github.com/lf-edge/eve/pkg/kube/cnirpc v0.0.0-20240315102754-0f6d1f182e0d/go.mod h1:Nn3juMJJ1G8dyHOebdZyS4jOB/fuxAd5fIajBaWjHr8=
593593
github.com/lf-edge/go-qemu v0.0.0-20231121152149-4c467eda0c56 h1:LmFp0jbNSwPLuxJA+nQ+mMQrQ53ESkvHP4CVMqR0zrY=

pkg/pillar/vendor/github.com/lf-edge/eve-libs/zedUpload/awsutil/s3sync.go

Lines changed: 14 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/pillar/vendor/github.com/lf-edge/eve-libs/zedUpload/datastore_aws.go

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/pillar/vendor/github.com/lf-edge/eve-libs/zedUpload/datastore_http.go

Lines changed: 19 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/pillar/vendor/github.com/lf-edge/eve-libs/zedUpload/datastore_sftp.go

Lines changed: 19 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/pillar/vendor/github.com/lf-edge/eve-libs/zedUpload/ociutil/oci.go

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/pillar/vendor/modules.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,7 @@ github.com/lf-edge/eve-api/go/metrics
898898
github.com/lf-edge/eve-api/go/nestedappinstancemetrics
899899
github.com/lf-edge/eve-api/go/profile
900900
github.com/lf-edge/eve-api/go/register
901-
# github.com/lf-edge/eve-libs v0.0.0-20251217132956-95b6654d8655
901+
# github.com/lf-edge/eve-libs v0.0.0-20260131092350-2a40e827255e
902902
## explicit; go 1.24.0
903903
github.com/lf-edge/eve-libs/depgraph
904904
github.com/lf-edge/eve-libs/nettrace

0 commit comments

Comments
 (0)