Skip to content

Commit b3410df

Browse files
committed
DUPLO-13771 add url component decoding in case the encode modified the token
1 parent 89d214f commit b3410df

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

internal/interactive.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"io"
88
"net"
99
"net/http"
10+
"net/url"
1011
"time"
1112

1213
"github.com/skratchdot/open-golang/open"
@@ -31,6 +32,12 @@ func handlerToken(baseUrl string, localPort int, admin bool, res http.ResponseWr
3132
http.Error(res, "missing token", http.StatusBadRequest)
3233
return true, nil
3334
}
35+
// URL-decode the token.
36+
decodedToken, err := url.QueryUnescape(token)
37+
if err != nil {
38+
http.Error(res, "invalid token encoding", http.StatusBadRequest)
39+
return true, nil
40+
}
3441
// Build the redirect URL back to Duplo with success=true.
3542
adminFlag := ""
3643
if admin {
@@ -39,7 +46,7 @@ func handlerToken(baseUrl string, localPort int, admin bool, res http.ResponseWr
3946
redirectURL := fmt.Sprintf("%s/app/user/verify-token?localAppName=duplo-jit&localPort=%d%s&success=true", baseUrl, localPort, adminFlag)
4047
// Issue an HTTP redirect.
4148
http.Redirect(res, req, redirectURL, http.StatusFound)
42-
return true, []byte(token)
49+
return true, []byte(decodedToken)
4350
}
4451

4552
// If it's a POST request, use legacy behavior.

0 commit comments

Comments
 (0)