Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't urlencode integer values #895

Merged
merged 1 commit into from
Jul 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/Github/Api/Apps.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function createInstallationToken($installationId, $userId = null)

$this->configurePreviewHeader();

return $this->post('/app/installations/'.rawurlencode($installationId).'/access_tokens', $parameters);
return $this->post('/app/installations/'.$installationId.'/access_tokens', $parameters);
}

/**
Expand Down Expand Up @@ -66,7 +66,7 @@ public function getInstallation($installationId)
{
$this->configurePreviewHeader();

return $this->get('/app/installations/'.rawurldecode($installationId));
return $this->get('/app/installations/'.$installationId);
}

/**
Expand Down Expand Up @@ -129,7 +129,7 @@ public function removeInstallation($installationId)
{
$this->configurePreviewHeader();

$this->delete('/app/installations/'.rawurldecode($installationId));
$this->delete('/app/installations/'.$installationId);
}

/**
Expand Down Expand Up @@ -167,7 +167,7 @@ public function addRepository($installationId, $repositoryId)
{
$this->configurePreviewHeader();

return $this->put('/installations/'.rawurlencode($installationId).'/repositories/'.rawurlencode($repositoryId));
return $this->put('/installations/'.$installationId.'/repositories/'.$repositoryId);
}

/**
Expand All @@ -184,6 +184,6 @@ public function removeRepository($installationId, $repositoryId)
{
$this->configurePreviewHeader();

return $this->delete('/installations/'.rawurlencode($installationId).'/repositories/'.rawurlencode($repositoryId));
return $this->delete('/installations/'.$installationId.'/repositories/'.$repositoryId);
}
}
10 changes: 5 additions & 5 deletions lib/Github/Api/CurrentUser/Notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function markAsReadInRepository($username, $repository, array $params = [
*/
public function markAsRead($id, array $params)
{
return $this->patch('/notifications/threads/'.rawurlencode($id), $params);
return $this->patch('/notifications/threads/'.$id, $params);
}

/**
Expand All @@ -97,7 +97,7 @@ public function markAsRead($id, array $params)
*/
public function show($id)
{
return $this->get('/notifications/threads/'.rawurlencode($id));
return $this->get('/notifications/threads/'.$id);
}

/**
Expand All @@ -111,7 +111,7 @@ public function show($id)
*/
public function showSubscription($id)
{
return $this->get('/notifications/threads/'.rawurlencode($id).'/subscription');
return $this->get('/notifications/threads/'.$id.'/subscription');
}

/**
Expand All @@ -126,7 +126,7 @@ public function showSubscription($id)
*/
public function createSubscription($id, array $params)
{
return $this->put('/notifications/threads/'.rawurlencode($id).'/subscription', $params);
return $this->put('/notifications/threads/'.$id.'/subscription', $params);
}

/**
Expand All @@ -140,6 +140,6 @@ public function createSubscription($id, array $params)
*/
public function removeSubscription($id)
{
return $this->delete('/notifications/threads/'.rawurlencode($id).'/subscription');
return $this->delete('/notifications/threads/'.$id.'/subscription');
}
}
4 changes: 2 additions & 2 deletions lib/Github/Api/CurrentUser/PublicKeys.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function all()
*/
public function show($id)
{
return $this->get('/user/keys/'.rawurlencode($id));
return $this->get('/user/keys/'.$id);
}

/**
Expand Down Expand Up @@ -69,6 +69,6 @@ public function create(array $params)
*/
public function remove($id)
{
return $this->delete('/user/keys/'.rawurlencode($id));
return $this->delete('/user/keys/'.$id);
}
}
6 changes: 3 additions & 3 deletions lib/Github/Api/Deployment.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function all($username, $repository, array $params = [])
*/
public function show($username, $repository, $id)
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/deployments/'.rawurlencode($id));
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/deployments/'.$id);
}

/**
Expand Down Expand Up @@ -88,7 +88,7 @@ public function updateStatus($username, $repository, $id, array $params)
throw new MissingArgumentException(['state']);
}

return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/deployments/'.rawurlencode($id).'/statuses', $params);
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/deployments/'.$id.'/statuses', $params);
}

/**
Expand All @@ -102,6 +102,6 @@ public function updateStatus($username, $repository, $id, array $params)
*/
public function getStatuses($username, $repository, $id)
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/deployments/'.rawurlencode($id).'/statuses');
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/deployments/'.$id.'/statuses');
}
}
6 changes: 3 additions & 3 deletions lib/Github/Api/Gist/Comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function all($gist)
*/
public function show($gist, $comment)
{
return $this->get('/gists/'.rawurlencode($gist).'/comments/'.rawurlencode($comment));
return $this->get('/gists/'.rawurlencode($gist).'/comments/'.$comment);
}

/**
Expand All @@ -83,7 +83,7 @@ public function create($gist, $body)
*/
public function update($gist, $comment_id, $body)
{
return $this->patch('/gists/'.rawurlencode($gist).'/comments/'.rawurlencode($comment_id), ['body' => $body]);
return $this->patch('/gists/'.rawurlencode($gist).'/comments/'.$comment_id, ['body' => $body]);
}

/**
Expand All @@ -96,6 +96,6 @@ public function update($gist, $comment_id, $body)
*/
public function remove($gist, $comment)
{
return $this->delete('/gists/'.rawurlencode($gist).'/comments/'.rawurlencode($comment));
return $this->delete('/gists/'.rawurlencode($gist).'/comments/'.$comment);
}
}
53 changes: 52 additions & 1 deletion lib/Github/Api/Gists.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ public function configure($bodyType = null)
return $this;
}

/**
* @param string|null $type
*
* @return array|string
*/
public function all($type = null)
{
if (!in_array($type, ['public', 'starred'])) {
Expand All @@ -46,6 +51,11 @@ public function all($type = null)
return $this->get('/gists/'.rawurlencode($type));
}

/**
* @param string $number
*
* @return array
*/
public function show($number)
{
return $this->get('/gists/'.rawurlencode($number));
Expand All @@ -54,7 +64,7 @@ public function show($number)
/**
* Get a specific revision of a gist.
*
* @param int $number
* @param string $number
* @param string $sha
*
* @link https://developer.github.com/v3/gists/#get-a-specific-revision-of-a-gist
Expand All @@ -77,41 +87,82 @@ public function create(array $params)
return $this->post('/gists', $params);
}

/**
* @param string $id
* @param array $params
*
* @return array
*/
public function update($id, array $params)
{
return $this->patch('/gists/'.rawurlencode($id), $params);
}

/**
* @param string $id
*
* @return array
*/
public function commits($id)
{
return $this->get('/gists/'.rawurlencode($id).'/commits');
}

/**
* @param string $id
*
* @return array
*/
public function fork($id)
{
return $this->post('/gists/'.rawurlencode($id).'/fork');
}

/**
* @param string $id
*
* @return array
*/
public function forks($id)
{
return $this->get('/gists/'.rawurlencode($id).'/forks');
}

/**
* @param string $id
*
* @return array
*/
public function remove($id)
{
return $this->delete('/gists/'.rawurlencode($id));
}

/**
* @param string $id
*
* @return array
*/
public function check($id)
{
return $this->get('/gists/'.rawurlencode($id).'/star');
}

/**
* @param string $id
*
* @return array
*/
public function star($id)
{
return $this->put('/gists/'.rawurlencode($id).'/star');
}

/**
* @param string $id
*
* @return array
*/
public function unstar($id)
{
return $this->delete('/gists/'.rawurlencode($id).'/star');
Expand Down
8 changes: 4 additions & 4 deletions lib/Github/Api/Issue.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function org($organization, $state, array $params = [])
*/
public function show($username, $repository, $id)
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.rawurlencode($id));
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.$id);
}

/**
Expand Down Expand Up @@ -154,7 +154,7 @@ public function create($username, $repository, array $params)
*/
public function update($username, $repository, $id, array $params)
{
return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.rawurlencode($id), $params);
return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.$id, $params);
}

/**
Expand All @@ -170,7 +170,7 @@ public function update($username, $repository, $id, array $params)
*/
public function lock($username, $repository, $id)
{
return $this->put('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.rawurlencode($id).'/lock');
return $this->put('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.$id.'/lock');
}

/**
Expand All @@ -186,7 +186,7 @@ public function lock($username, $repository, $id)
*/
public function unlock($username, $repository, $id)
{
return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.rawurlencode($id).'/lock');
return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.$id.'/lock');
}

/**
Expand Down
10 changes: 5 additions & 5 deletions lib/Github/Api/Issue/Comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function all($username, $repository, $issue, $page = 1)
];
}

return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.rawurlencode($issue).'/comments', $parameters);
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.$issue.'/comments', $parameters);
}

/**
Expand All @@ -75,7 +75,7 @@ public function all($username, $repository, $issue, $page = 1)
*/
public function show($username, $repository, $comment)
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/comments/'.rawurlencode($comment));
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/comments/'.$comment);
}

/**
Expand All @@ -98,7 +98,7 @@ public function create($username, $repository, $issue, array $params)
throw new MissingArgumentException('body');
}

return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.rawurlencode($issue).'/comments', $params);
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.$issue.'/comments', $params);
}

/**
Expand All @@ -121,7 +121,7 @@ public function update($username, $repository, $comment, array $params)
throw new MissingArgumentException('body');
}

return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/comments/'.rawurlencode($comment), $params);
return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/comments/'.$comment, $params);
}

/**
Expand All @@ -137,6 +137,6 @@ public function update($username, $repository, $comment, array $params)
*/
public function remove($username, $repository, $comment)
{
return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/comments/'.rawurlencode($comment));
return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/comments/'.$comment);
}
}
2 changes: 1 addition & 1 deletion lib/Github/Api/Issue/Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Events extends AbstractApi
public function all($username, $repository, $issue = null, $page = 1)
{
if (null !== $issue) {
$path = '/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.rawurlencode($issue).'/events';
$path = '/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.$issue.'/events';
} else {
$path = '/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/events';
}
Expand Down
Loading