Skip to content

Commit 8e0ef82

Browse files
committed
Fix issue with spaces in params
1 parent e9d5885 commit 8e0ef82

7 files changed

Lines changed: 42 additions & 28 deletions

File tree

CLAUDE.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,18 @@ via Postman's public gateway.
3535
go build -o webex .
3636
```
3737

38-
For release builds with embedded credentials (via goreleaser):
38+
## Releasing
39+
40+
Releases are handled by a GitHub Actions workflow triggered by pushing a tag.
41+
Do **not** run `goreleaser` locally — it requires secrets (e.g. `WEBEX_CLIENT_ID`)
42+
that are only available in CI.
43+
3944
```bash
40-
goreleaser release --snapshot --clean
45+
git tag v0.X.0
46+
git push origin v0.X.0
47+
# Then set the release notes via gh:
48+
gh release edit v0.X.0 --title "v0.X.0" --notes "## Improvements
49+
* ..."
4150
```
4251

4352
## Module Path

cmd/calling/custom_announcements.go

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package calling
22

33
import (
44
"fmt"
5+
"net/url"
56
"os"
67
"path/filepath"
78
"strings"
@@ -96,11 +97,11 @@ Examples:
9697
webex calling announcement-repository upload-binary-greeting --file greeting.wav --name "Main Greeting" --dry-run`,
9798
"POST",
9899
func(orgID, _, _ string) string {
99-
url := config.CallingBaseURL + "/telephony/config/announcements"
100+
u := config.CallingBaseURL + "/telephony/config/announcements"
100101
if orgID != "" {
101-
url += "?orgId=" + orgID
102+
u += "?orgId=" + url.QueryEscape(orgID)
102103
}
103-
return url
104+
return u
104105
},
105106
false, false,
106107
)
@@ -119,11 +120,11 @@ Examples:
119120
webex calling announcement-repository upload-binary-greeting-2 --file greeting.wav --name "Lobby Greeting" --location-id <loc-id> --dry-run`,
120121
"POST",
121122
func(orgID, locationID, _ string) string {
122-
url := config.CallingBaseURL + "/telephony/config/locations/" + locationID + "/announcements"
123+
u := config.CallingBaseURL + "/telephony/config/locations/" + url.PathEscape(locationID) + "/announcements"
123124
if orgID != "" {
124-
url += "?orgId=" + orgID
125+
u += "?orgId=" + url.QueryEscape(orgID)
125126
}
126-
return url
127+
return u
127128
},
128129
true, false,
129130
)
@@ -142,11 +143,11 @@ Examples:
142143
webex calling announcement-repository update-binary-greeting --file greeting.wav --name "Updated Greeting" --announcement-id <ann-id> --dry-run`,
143144
"PUT",
144145
func(orgID, _, announcementID string) string {
145-
url := config.CallingBaseURL + "/telephony/config/announcements/" + announcementID
146+
u := config.CallingBaseURL + "/telephony/config/announcements/" + url.PathEscape(announcementID)
146147
if orgID != "" {
147-
url += "?orgId=" + orgID
148+
u += "?orgId=" + url.QueryEscape(orgID)
148149
}
149-
return url
150+
return u
150151
},
151152
false, true,
152153
)
@@ -164,11 +165,11 @@ Examples:
164165
webex calling announcement-repository update-binary-greeting-2 --file greeting.wav --name "Updated Greeting" --location-id <loc-id> --announcement-id <ann-id>`,
165166
"PUT",
166167
func(orgID, locationID, announcementID string) string {
167-
url := config.CallingBaseURL + "/telephony/config/locations/" + locationID + "/announcements/" + announcementID
168+
u := config.CallingBaseURL + "/telephony/config/locations/" + url.PathEscape(locationID) + "/announcements/" + url.PathEscape(announcementID)
168169
if orgID != "" {
169-
url += "?orgId=" + orgID
170+
u += "?orgId=" + url.QueryEscape(orgID)
170171
}
171-
return url
172+
return u
172173
},
173174
true, true,
174175
)

cmd/calling/custom_voicemail_greetings.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package calling
22

33
import (
44
"fmt"
5+
"net/url"
56
"os"
67
"path/filepath"
78

@@ -165,9 +166,9 @@ func registerGreetingUpload(parentCmd *cobra.Command, use, short, long string,
165166
if entityFlag != "" {
166167
path = replaceEntityID(path, entityID)
167168
}
168-
url := config.CallingBaseURL + path
169+
u := config.CallingBaseURL + path
169170
if orgID != "" {
170-
url += "?orgId=" + orgID
171+
u += "?orgId=" + url.QueryEscape(orgID)
171172
}
172173

173174
parts := []audio.MultipartPart{
@@ -179,7 +180,7 @@ func registerGreetingUpload(parentCmd *cobra.Command, use, short, long string,
179180
},
180181
}
181182

182-
body, statusCode, err := audio.UploadMultipart("POST", url, parts)
183+
body, statusCode, err := audio.UploadMultipart("POST", u, parts)
183184
if err != nil {
184185
return err
185186
}
@@ -205,7 +206,7 @@ func replaceEntityID(path, id string) string {
205206
result := path
206207
for _, placeholder := range []string{"{entityId}"} {
207208
if idx := len(result); idx > 0 {
208-
result = replaceFirst(result, placeholder, id)
209+
result = replaceFirst(result, placeholder, url.PathEscape(id))
209210
}
210211
}
211212
return result

cmd/cc/custom_agent_greetings.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package cc
33
import (
44
"encoding/json"
55
"fmt"
6+
"net/url"
67
"os"
78
"path/filepath"
89
"strings"
@@ -113,7 +114,7 @@ Examples:
113114
name += ".wav"
114115
}
115116

116-
url := config.CcBaseURL + "/organization/" + orgid + "/v2/agent-personal-greeting"
117+
u := config.CcBaseURL + "/organization/" + url.PathEscape(orgid) + "/v2/agent-personal-greeting"
117118

118119
info := map[string]any{
119120
"agentId": agentID,
@@ -139,7 +140,7 @@ Examples:
139140
},
140141
}
141142

142-
body, statusCode, err := audio.UploadMultipart("POST", url, parts)
143+
body, statusCode, err := audio.UploadMultipart("POST", u, parts)
143144
if err != nil {
144145
return err
145146
}

cmd/cc/custom_audio_files.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package cc
33
import (
44
"encoding/json"
55
"fmt"
6+
"net/url"
67
"os"
78
"path/filepath"
89
"strings"
@@ -113,7 +114,7 @@ Examples:
113114
name += ".wav"
114115
}
115116

116-
url := config.CcBaseURL + "/organization/" + orgid + "/audio-file"
117+
u := config.CcBaseURL + "/organization/" + url.PathEscape(orgid) + "/audio-file"
117118

118119
info := map[string]any{
119120
"name": name,
@@ -139,7 +140,7 @@ Examples:
139140
},
140141
}
141142

142-
body, statusCode, err := audio.UploadMultipart("POST", url, parts)
143+
body, statusCode, err := audio.UploadMultipart("POST", u, parts)
143144
if err != nil {
144145
return err
145146
}

internal/auth/oauth.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ func fetchIdentity(accessToken string) (*identityInfo, error) {
260260
}
261261

262262
func FetchOrgName(accessToken, orgID string) (string, error) {
263-
req, _ := http.NewRequest("GET", "https://webexapis.com/v1/organizations/"+orgID, nil)
263+
req, _ := http.NewRequest("GET", "https://webexapis.com/v1/organizations/"+url.PathEscape(orgID), nil)
264264
req.Header.Set("Authorization", "Bearer "+accessToken)
265265

266266
resp, err := http.DefaultClient.Do(req)

internal/client/client.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"io"
77
"net/http"
8+
urlpkg "net/url"
89
"os"
910
"strings"
1011

@@ -33,19 +34,19 @@ func doOnce(req *Request) ([]byte, int, error) {
3334
// Build URL
3435
url := req.baseURL + req.path
3536
for k, v := range req.pathParams {
36-
url = strings.ReplaceAll(url, "{"+k+"}", v)
37+
url = strings.ReplaceAll(url, "{"+k+"}", urlpkg.PathEscape(v))
3738
}
3839

3940
// Add query params
4041
if len(req.queryParams) > 0 {
41-
parts := make([]string, 0, len(req.queryParams))
42+
params := urlpkg.Values{}
4243
for k, v := range req.queryParams {
4344
if v != "" {
44-
parts = append(parts, fmt.Sprintf("%s=%s", k, v))
45+
params.Set(k, v)
4546
}
4647
}
47-
if len(parts) > 0 {
48-
url += "?" + strings.Join(parts, "&")
48+
if encoded := params.Encode(); encoded != "" {
49+
url += "?" + encoded
4950
}
5051
}
5152

0 commit comments

Comments
 (0)