Skip to content

Commit

Permalink
Escape unicode while generating redirect_to url for oauth (TykTechnol…
Browse files Browse the repository at this point in the history
  • Loading branch information
furkansenharputlu authored Dec 11, 2019
1 parent 59fc7fb commit fa0caf3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 5 additions & 2 deletions gateway/oauth_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,14 @@ func (o *OAuthHandlers) generateOAuthOutputFromOsinResponse(osinResponse *osin.R
osinResponse.Output["redirect_to"] = redirect
}

respData, err := json.Marshal(&osinResponse.Output)
buffer := &bytes.Buffer{}
encoder := json.NewEncoder(buffer)
encoder.SetEscapeHTML(false)
err = encoder.Encode(&osinResponse.Output)
if err != nil {
return nil
}
return respData
return buffer.Bytes()
}

func (o *OAuthHandlers) notifyClientOfNewOauth(notification NewOAuthNotification) {
Expand Down
5 changes: 3 additions & 2 deletions gateway/oauth_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,14 +378,15 @@ func TestAPIClientAuthorizeToken(t *testing.T) {
"Content-Type": "application/x-www-form-urlencoded",
}

ts.Run(t, test.TestCase{
_, _ = ts.Run(t, test.TestCase{
Path: "/APIID/tyk/oauth/authorize-client/",
AdminAuth: true,
Data: param.Encode(),
Headers: headers,
Method: http.MethodPost,
Code: http.StatusOK,
BodyMatch: `"access_token"`,
BodyMatch: `{"access_token":".*","expires_in":3600,"redirect_to":"http://client.oauth.com` +
`#access_token=.*=&expires_in=3600&token_type=bearer","token_type":"bearer"}`,
})
})
}
Expand Down

0 comments on commit fa0caf3

Please sign in to comment.