Skip to content

Commit

Permalink
Replacing + with %20 in URL query strings
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardsp committed Jan 26, 2023
1 parent 78f7287 commit 016fc05
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion cmd/lhsm-plugin-az-core/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"net/url"
"path"
"strings"

"github.com/Azure/azure-pipeline-go/pipeline"
"github.com/Azure/azure-storage-blob-go/azblob"
Expand All @@ -24,7 +25,7 @@ type RemoveOptions struct {
func Remove(o RemoveOptions) error {
ctx := context.TODO()
p := azblob.NewPipeline(o.Credential, azblob.PipelineOptions{})
blobPath := url.QueryEscape(path.Join(o.ContainerName, o.ExportPrefix, o.BlobName))
blobPath := strings.Replace(url.QueryEscape(path.Join(o.ContainerName, o.ExportPrefix, o.BlobName)), "+", "%20", -1)
u, _ := url.Parse(fmt.Sprintf("https://%s.%s/%s%s", o.AccountName, o.AccountSuffix, blobPath, o.ResourceSAS))

util.Log(pipeline.LogInfo, fmt.Sprintf("Removing %s.", u.String()))
Expand Down
3 changes: 2 additions & 1 deletion cmd/lhsm-plugin-az-core/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"net/url"
"os"
"path"
"strings"

"github.com/Azure/azure-pipeline-go/pipeline"
"github.com/Azure/azure-storage-blob-go/azblob"
Expand Down Expand Up @@ -39,7 +40,7 @@ func Restore(o RestoreOptions) (int64, error) {
defer cancel()

p := util.NewPipeline(ctx, o.Credential, o.Pacer, azblob.PipelineOptions{HTTPSender: util.HTTPClientFactory(o.HTTPClient)})
blobPath := url.QueryEscape(path.Join(o.ContainerName, o.ExportPrefix, o.BlobName))
blobPath := strings.Replace(url.QueryEscape(path.Join(o.ContainerName, o.ExportPrefix, o.BlobName)), "+", "%20", -1)

u, _ := url.Parse(fmt.Sprintf("https://%s.%s/%s%s", o.AccountName, o.AccountSuffix, blobPath, o.ResourceSAS))

Expand Down

0 comments on commit 016fc05

Please sign in to comment.