You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by mi...@apache.org on 2018/11/06 20:09:18 UTC
[trafficcontrol] 01/02: escape bare names
This is an automated email from the ASF dual-hosted git repository.
mitchell852 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
commit aa07cea3cbf475d3124131350ea172ca3d95fe96
Author: Dan Kirkwood <da...@apache.org>
AuthorDate: Mon Nov 5 16:35:20 2018 -0700
escape bare names
---
traffic_ops/client/cachegroup.go | 5 +++--
traffic_ops/client/cdn.go | 3 ++-
traffic_ops/client/deliveryservice_requests.go | 3 ++-
traffic_ops/client/origin.go | 3 ++-
traffic_ops/client/phys_location.go | 3 ++-
traffic_ops/client/region.go | 5 +++--
traffic_ops/client/role.go | 3 ++-
traffic_ops/client/traffic_monitor.go | 1 +
8 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/traffic_ops/client/cachegroup.go b/traffic_ops/client/cachegroup.go
index e0dd5ad..ad43ced 100644
--- a/traffic_ops/client/cachegroup.go
+++ b/traffic_ops/client/cachegroup.go
@@ -21,6 +21,7 @@ import (
"fmt"
"net"
"net/http"
+ "net/url"
"github.com/apache/trafficcontrol/lib/go-tc"
)
@@ -253,7 +254,7 @@ func (to *Session) GetCacheGroupByID(id int) ([]tc.CacheGroup, ReqInf, error) {
// GET a CacheGroup by the CacheGroup name
func (to *Session) GetCacheGroupNullableByName(name string) ([]tc.CacheGroupNullable, ReqInf, error) {
- url := fmt.Sprintf("%s?name=%s", API_v13_CacheGroups, name)
+ url := fmt.Sprintf("%s?name=%s", API_v13_CacheGroups, url.QueryEscape(name))
resp, remoteAddr, err := to.request(http.MethodGet, url, nil)
reqInf := ReqInf{CacheHitStatus: CacheHitStatusMiss, RemoteAddr: remoteAddr}
if err != nil {
@@ -272,7 +273,7 @@ func (to *Session) GetCacheGroupNullableByName(name string) ([]tc.CacheGroupNull
// GET a CacheGroup by the CacheGroup name
// Deprecated: use GetCachegroupNullableByName
func (to *Session) GetCacheGroupByName(name string) ([]tc.CacheGroup, ReqInf, error) {
- url := fmt.Sprintf("%s?name=%s", API_v13_CacheGroups, name)
+ url := fmt.Sprintf("%s?name=%s", API_v13_CacheGroups, url.QueryEscape(name))
resp, remoteAddr, err := to.request(http.MethodGet, url, nil)
reqInf := ReqInf{CacheHitStatus: CacheHitStatusMiss, RemoteAddr: remoteAddr}
if err != nil {
diff --git a/traffic_ops/client/cdn.go b/traffic_ops/client/cdn.go
index 008f384..4503a78 100644
--- a/traffic_ops/client/cdn.go
+++ b/traffic_ops/client/cdn.go
@@ -20,6 +20,7 @@ import (
"fmt"
"net"
"net/http"
+ "net/url"
"github.com/apache/trafficcontrol/lib/go-tc"
)
@@ -101,7 +102,7 @@ func (to *Session) GetCDNByID(id int) ([]tc.CDN, ReqInf, error) {
// GET a CDN by the CDN name
func (to *Session) GetCDNByName(name string) ([]tc.CDN, ReqInf, error) {
- url := fmt.Sprintf("%s?name=%s", API_v13_CDNs, name)
+ url := fmt.Sprintf("%s?name=%s", API_v13_CDNs, url.QueryEscape(name))
resp, remoteAddr, err := to.request(http.MethodGet, url, nil)
reqInf := ReqInf{CacheHitStatus: CacheHitStatusMiss, RemoteAddr: remoteAddr}
if err != nil {
diff --git a/traffic_ops/client/deliveryservice_requests.go b/traffic_ops/client/deliveryservice_requests.go
index e01182d..249506c 100644
--- a/traffic_ops/client/deliveryservice_requests.go
+++ b/traffic_ops/client/deliveryservice_requests.go
@@ -22,6 +22,7 @@ import (
"io/ioutil"
"net"
"net/http"
+ "net/url"
"github.com/apache/trafficcontrol/lib/go-tc"
)
@@ -131,7 +132,7 @@ func (to *Session) GetDeliveryServiceRequests() ([]tc.DeliveryServiceRequest, Re
// GET a DeliveryServiceRequest by the DeliveryServiceRequest XMLID
func (to *Session) GetDeliveryServiceRequestByXMLID(XMLID string) ([]tc.DeliveryServiceRequest, ReqInf, error) {
- route := fmt.Sprintf("%s?xmlId=%s", API_DS_REQUESTS, XMLID)
+ route := fmt.Sprintf("%s?xmlId=%s", API_DS_REQUESTS, url.QueryEscape(XMLID))
resp, remoteAddr, err := to.request(http.MethodGet, route, nil)
reqInf := ReqInf{CacheHitStatus: CacheHitStatusMiss, RemoteAddr: remoteAddr}
diff --git a/traffic_ops/client/origin.go b/traffic_ops/client/origin.go
index 9e89d66..222b249 100644
--- a/traffic_ops/client/origin.go
+++ b/traffic_ops/client/origin.go
@@ -21,6 +21,7 @@ import (
"fmt"
"net"
"net/http"
+ "net/url"
"github.com/apache/trafficcontrol/lib/go-tc"
)
@@ -168,7 +169,7 @@ func (to *Session) GetOriginByID(id int) ([]tc.Origin, ReqInf, error) {
// GET an Origin by the Origin name
func (to *Session) GetOriginByName(name string) ([]tc.Origin, ReqInf, error) {
- return to.GetOriginsByQueryParams(fmt.Sprintf("?name=%s", name))
+ return to.GetOriginsByQueryParams(fmt.Sprintf("?name=%s", url.QueryEscape(name)))
}
// GET a list of Origins by Delivery Service ID
diff --git a/traffic_ops/client/phys_location.go b/traffic_ops/client/phys_location.go
index baa326f..3ce2261 100644
--- a/traffic_ops/client/phys_location.go
+++ b/traffic_ops/client/phys_location.go
@@ -21,6 +21,7 @@ import (
"fmt"
"net"
"net/http"
+ "net/url"
"github.com/apache/trafficcontrol/lib/go-tc"
)
@@ -111,7 +112,7 @@ func (to *Session) GetPhysLocationByID(id int) ([]tc.PhysLocation, ReqInf, error
// GET a PhysLocation by the PhysLocation name
func (to *Session) GetPhysLocationByName(name string) ([]tc.PhysLocation, ReqInf, error) {
- url := fmt.Sprintf("%s?name=%s", API_v13_PhysLocations, name)
+ url := fmt.Sprintf("%s?name=%s", API_v13_PhysLocations, url.QueryEscape(name))
resp, remoteAddr, err := to.request(http.MethodGet, url, nil)
reqInf := ReqInf{CacheHitStatus: CacheHitStatusMiss, RemoteAddr: remoteAddr}
if err != nil {
diff --git a/traffic_ops/client/region.go b/traffic_ops/client/region.go
index 5eb4df8..5d9146e 100644
--- a/traffic_ops/client/region.go
+++ b/traffic_ops/client/region.go
@@ -21,6 +21,7 @@ import (
"fmt"
"net"
"net/http"
+ "net/url"
"github.com/apache/trafficcontrol/lib/go-tc"
)
@@ -112,7 +113,7 @@ func (to *Session) GetRegionByID(id int) ([]tc.Region, ReqInf, error) {
// GET a Region by the Region name
func (to *Session) GetRegionByName(name string) ([]tc.Region, ReqInf, error) {
- url := fmt.Sprintf("%s?name=%s", API_v13_REGIONS, name)
+ url := fmt.Sprintf("%s?name=%s", API_v13_REGIONS, url.QueryEscape(name))
resp, remoteAddr, err := to.request(http.MethodGet, url, nil)
reqInf := ReqInf{CacheHitStatus: CacheHitStatusMiss, RemoteAddr: remoteAddr}
if err != nil {
@@ -144,7 +145,7 @@ func (to *Session) DeleteRegionByID(id int) (tc.Alerts, ReqInf, error) {
// GetRegionByNamePath gets a region by name, using the /api/version/region/name path. This gets the same data as GetRegionByName, but uses a different API path to get the same data, and returns a slightly different format.
func (to *Session) GetRegionByNamePath(name string) ([]tc.RegionName, ReqInf, error) {
- url := apiBase + `/regions/name/` + name
+ url := apiBase + `/regions/name/` + url.QueryEscape(name)
reqResp, remoteAddr, err := to.request(http.MethodGet, url, nil)
reqInf := ReqInf{CacheHitStatus: CacheHitStatusMiss, RemoteAddr: remoteAddr}
if err != nil {
diff --git a/traffic_ops/client/role.go b/traffic_ops/client/role.go
index d403cfc..5e0c185 100644
--- a/traffic_ops/client/role.go
+++ b/traffic_ops/client/role.go
@@ -20,6 +20,7 @@ import (
"fmt"
"net"
"net/http"
+ "net/url"
"github.com/apache/trafficcontrol/lib/go-tc"
)
@@ -106,7 +107,7 @@ func (to *Session) GetRoleByID(id int) ([]tc.Role, ReqInf, int, error) {
// GET a Role by the Role name
func (to *Session) GetRoleByName(name string) ([]tc.Role, ReqInf, int, error) {
- url := fmt.Sprintf("%s?name=%s", API_v13_ROLES, name)
+ url := fmt.Sprintf("%s?name=%s", API_v13_ROLES, url.QueryEscape(name))
resp, remoteAddr, errClient := to.rawRequest(http.MethodGet, url, nil)
reqInf := ReqInf{CacheHitStatus: CacheHitStatusMiss, RemoteAddr: remoteAddr}
if resp != nil {
diff --git a/traffic_ops/client/traffic_monitor.go b/traffic_ops/client/traffic_monitor.go
index 73905a6..bd8528a 100644
--- a/traffic_ops/client/traffic_monitor.go
+++ b/traffic_ops/client/traffic_monitor.go
@@ -3,6 +3,7 @@ package client
import (
"encoding/json"
"fmt"
+
"github.com/apache/trafficcontrol/lib/go-tc"
)