Repository navigation
Conversation
Without a format, requestToken() sent no Accept header, so GitHub answered form-encoded and the token was lost when the body was decoded as JSON. getAuthorizationLink() left scope and state unencoded, because Joomla\Uri\Uri does not encode the query values it renders: a scope of "repo user" produced a literal space and a state containing "&" could add parameters. Request JSON by default and build the authorization link with http_build_query(PHP_QUERY_RFC3986). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Changes
Authorization::requestToken()with the default$format = ''sent noAcceptheader, so GitHub answeredaccess_token=…&scope=…(form-encoded).processResponse()json-decoded that tonulland the token was lost. Without a format it now sendsAccept: application/json, so the method returns the decoded object (access_token,scope,token_type). The@returndoc block saidstring; it is an object.Authorization::getAuthorizationLink()urlencoded onlyredirect_uri.Joomla\Uri\Uridoes not encode the query values it renders, so a scope ofrepo userproduced a literal space and an attacker-influencedstatecontaining&could inject parameters (…&scope=repo user&state=st&scope=admin). The link is now built withhttp_build_query(…, PHP_QUERY_RFC3986). This works with the currentjoomla/uri.requestToken($format = 'xml')still json-decodes the XML answer (and returnsnull); that was not part of the report and is left as is.Testing Instructions
AuthorizationsTest::testRequestTokennow checks the request (data andAcceptheader) and the decoded token;testGetAuthorizationLinkEncodesValueschecks the encoding ofredirect_uri,scopeandstate. Both fail before the change.Documentation Changes Required
docs/overview.md: new section "OAuth web application flow". #66'spackages.mdlistsgetAuthorizationLink/requestTokenwithout details; nothing to adjust there.🤖 Generated with Claude Code