Repository navigation
Commit 329da7f
committed
browser: open AbsoluteUri to avoid double-escaping
GCM launches the system browser for interactive OAuth by handing the
authorization URL to the OS "shell execute" handler. On macOS that is
/usr/bin/open, which validates the URL and, on finding any character
that is not legal in a fully percent-encoded URL, re-encodes the whole
query string. That step double-escapes parameters we had already
encoded -- redirect_uri=http%3A%2F%2F... becomes
redirect_uri=http%253A%252F%252F... -- and the authorization server
rejects the redirect. Windows ShellExecuteEx forwards the string
verbatim, so only macOS is affected.
The trigger was a raw space in the query. Uri.ToString() is a display
form that unescapes %20 back to a literal space (while leaving %2F
alone), so building the launch string that way reintroduced spaces,
most easily via the space-delimited scope parameter. This surfaced
after MSAL began encoding spaces[1] as %20 rather than +; a literal
+ is left untouched by ToString(), which had masked the problem.
Uri.AbsoluteUri keeps the query fully percent-encoded, so %20 stays
%20 and macOS open accepts the URL unchanged.
[1]: AzureAD/microsoft-authentication-library-for-dotnet#5128
Assisted-by: Claude Opus 4.8
Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>1 parent 1c0b910 commit 329da7f
1 file changed
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
70 | 76 | | |
71 | 77 | | |
72 | 78 | | |
| |||
0 commit comments