diff --git a/Makefile b/Makefile index dcfa0d7..d01bf82 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ test: lint: ${LINT} run --build-tags=all - DIFF=$$(${FORMATTER} -d core); if [[ -n "$$DIFF" ]]; then printf "\n$$DIFF" && exit 1; fi + DIFF=$$(${FORMATTER} -d core); if [ -n "$$DIFF" ]; then printf "\n$$DIFF\n" && exit 1; fi scan-gosec: ${GOSEC} ./... diff --git a/core/request_builder.go b/core/request_builder.go index be82b47..e0c7f28 100644 --- a/core/request_builder.go +++ b/core/request_builder.go @@ -152,6 +152,14 @@ func (requestBuilder *RequestBuilder) ResolveRequestURL(serviceURL string, path // If we have a non-empty "path" input parameter, then process it for possible path param references. if path != "" { + // Encode the unresolved path string. This will convert all special characters to their + // "%" encoding counterparts. Then we need to revert the encodings for '/', '{' and '}' characters + // to retain the original path segments and to make it easy to insert the encoded path param values below. + path = url.PathEscape(path) + path = strings.ReplaceAll(path, "%2F", "/") + path = strings.ReplaceAll(path, "%7B", "{") + path = strings.ReplaceAll(path, "%7D", "}") + // If path parameter values were passed in, then for each one, replace any references to it // within "path" with the path parameter's encoded value. if len(pathParams) > 0 { diff --git a/core/sdk_problem_test.go b/core/sdk_problem_test.go index 7959adf..7a7c5dc 100644 --- a/core/sdk_problem_test.go +++ b/core/sdk_problem_test.go @@ -239,7 +239,7 @@ func TestSDKErrorfNoSummary(t *testing.T) { } func TestSDKErrorfDoesntUseSDKCausedBy(t *testing.T) { - sdkProb := getPopulatedSDKProblem(); + sdkProb := getPopulatedSDKProblem() newSDKProb := SDKErrorf(sdkProb, "", "", NewProblemComponent("a", "b")) assert.Nil(t, newSDKProb.causedBy) assert.NotNil(t, newSDKProb.nativeCausedBy) diff --git a/core/sdk_problem_utils.go b/core/sdk_problem_utils.go index 080a1bf..4883833 100644 --- a/core/sdk_problem_utils.go +++ b/core/sdk_problem_utils.go @@ -108,13 +108,13 @@ func formatFrames(pcs []uintptr, componentName string) []sdkStackFrame { } type sparseSDKProblem struct { - ID string + ID string Function string } func newSparseSDKProblem(prob *SDKProblem) *sparseSDKProblem { return &sparseSDKProblem{ - ID: prob.GetID(), + ID: prob.GetID(), Function: prob.Function, } }