Skip to content

Commit

Permalink
Merge pull request #102 from stempher/bugfix/security-role
Browse files Browse the repository at this point in the history
escape url variables
  • Loading branch information
stevie- authored Aug 22, 2022
2 parents cd5ce38 + f229de2 commit e3c3c1c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions nexus3/pkg/security/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"io"
"net/http"
"net/url"

"github.com/datadrivers/go-nexus-client/nexus3/pkg/client"
"github.com/datadrivers/go-nexus-client/nexus3/schema/security"
Expand Down Expand Up @@ -53,7 +54,9 @@ func (s *SecurityRoleService) Create(role security.Role) error {
}

func (s *SecurityRoleService) Get(id string) (*security.Role, error) {
body, resp, err := s.Client.Get(fmt.Sprintf("%s/%s", securityrolesAPIEndpoint, id), nil)
encodedID := url.PathEscape(id)

body, resp, err := s.Client.Get(fmt.Sprintf("%s/%s", securityrolesAPIEndpoint, encodedID), nil)
if err != nil {
return nil, err
}
Expand All @@ -71,12 +74,14 @@ func (s *SecurityRoleService) Get(id string) (*security.Role, error) {
}

func (s *SecurityRoleService) Update(id string, role security.Role) error {
encodedID := url.PathEscape(id)

ioReader, err := roleIOReader(role)
if err != nil {
return err
}

body, resp, err := s.Client.Put(fmt.Sprintf("%s/%s", securityrolesAPIEndpoint, id), ioReader)
body, resp, err := s.Client.Put(fmt.Sprintf("%s/%s", securityrolesAPIEndpoint, encodedID), ioReader)
if err != nil {
return err
}
Expand All @@ -89,7 +94,9 @@ func (s *SecurityRoleService) Update(id string, role security.Role) error {
}

func (s *SecurityRoleService) Delete(id string) error {
body, resp, err := s.Client.Delete(fmt.Sprintf("%s/%s", securityrolesAPIEndpoint, id))
encodedID := url.PathEscape(id)

body, resp, err := s.Client.Delete(fmt.Sprintf("%s/%s", securityrolesAPIEndpoint, encodedID))
if err != nil {
return err
}
Expand Down

0 comments on commit e3c3c1c

Please sign in to comment.