-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix typos * Fix encoding spaces in issuer name
- Loading branch information
Showing
7 changed files
with
63 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package internal | ||
|
||
import ( | ||
"net/url" | ||
"sort" | ||
"strings" | ||
) | ||
|
||
// EncodeQuery is a copy-paste of url.Values.Encode, except it uses %20 instead | ||
// of + to encode spaces. This is necessary to correctly render spaces in some | ||
// authenticator apps, like Google Authenticator. | ||
func EncodeQuery(v url.Values) string { | ||
if v == nil { | ||
return "" | ||
} | ||
var buf strings.Builder | ||
keys := make([]string, 0, len(v)) | ||
for k := range v { | ||
keys = append(keys, k) | ||
} | ||
sort.Strings(keys) | ||
for _, k := range keys { | ||
vs := v[k] | ||
keyEscaped := url.PathEscape(k) // changed from url.QueryEscape | ||
for _, v := range vs { | ||
if buf.Len() > 0 { | ||
buf.WriteByte('&') | ||
} | ||
buf.WriteString(keyEscaped) | ||
buf.WriteByte('=') | ||
buf.WriteString(url.PathEscape(v)) // changed from url.QueryEscape | ||
} | ||
} | ||
return buf.String() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters