Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Space not properly escaped #40

@pchristopher1275

Description

@pchristopher1275

I was getting signature failures when a query parameter had a properly escaped space. I replaced the existing escape method with url.QueryEscape and fixed. Patch below.

diff --git a/oauth.go b/oauth.go
index d8e0ea2..07cccac 100644
--- a/oauth.go
+++ b/oauth.go
@@ -957,23 +957,7 @@ func (s *RSASigner) SignatureMethod() string {
 }

 func escape(s string) string {
-       t := make([]byte, 0, 3*len(s))
-       for i := 0; i < len(s); i++ {
-               c := s[i]
-               if isEscapable(c) {
-                       t = append(t, '%')
-                       t = append(t, "0123456789ABCDEF"[c>>4])
-                       t = append(t, "0123456789ABCDEF"[c&15])
-               } else {
-                       t = append(t, s[i])
-               }
-       }
-       return string(t)
-}
-
-func isEscapable(b byte) bool {
-       return !('A' <= b && b <= 'Z' || 'a' <= b && b <= 'z' || '0' <= b && b <= '9' || b == '-' || b == '.' || b == '_' || b == '~')
-
+       return url.QueryEscape(s)
 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions