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

Add a bunch of missing urllib.parse.quote calls #1976

Merged
merged 57 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
7c1ece1
Add a bunch of missing urllib.parse.quote calls
ExplodingCabbage Jun 17, 2021
81ea860
Merge commit '554b2b28db8e3c06915406cb10e39aceb38d16d7'
ExplodingCabbage Nov 27, 2023
a4f7704
Merge commit 'b94a83cbf328bbcdabeaaaef572d5ca360e1dbba'
ExplodingCabbage Nov 27, 2023
36a04f4
Merge commit '6a21761e0f7cbac184d5188a1cb2f7a631619825'
ExplodingCabbage Nov 27, 2023
5d38ee9
Merge commit '6d4b6d1419f6b290a3e105ddc04334a2f24e5468'
ExplodingCabbage Nov 27, 2023
0de9091
Merge commit '006766f9856224eccd37485b90e56e8deb87a37a'
ExplodingCabbage Nov 27, 2023
81befbc
Merge commit 'e66c163a96df94d001aaf68dd45c879b0c3adc08'
ExplodingCabbage Nov 27, 2023
da96db6
Merge commit '0bb72ca0047924e5b8dbdb3608547b54e6b13908'
ExplodingCabbage Nov 27, 2023
0412ee6
Merge commit '99155806ed1becf8bb0eda12f070991b3abf10e1'
ExplodingCabbage Nov 27, 2023
af705c4
Merge commit '0177f7c51327039c8b96b7ebb2731e32b20a8eae'
ExplodingCabbage Nov 27, 2023
18265d0
Merge commit '7324110249002b24b38157e11ef312de00072ce0'
ExplodingCabbage Nov 27, 2023
411b586
Merge commit '50e26d566f8b6fcd2fa4e57e630521472914796e'
ExplodingCabbage Nov 27, 2023
b89d2ce
Merge commit '3c880e7669097deee1270c69884453a7e2a75f4c'
ExplodingCabbage Nov 27, 2023
294a9f6
Merge commit '766df993da59aec410178576bdc563d59a58568a'
ExplodingCabbage Nov 27, 2023
431cba1
Merge commit '91b3f40f790a9521225778c73a38cc0fe109f20f'
ExplodingCabbage Nov 27, 2023
b135d2e
Merge commit 'de80ff4b914b9ffd47347d60b14cbf270e07f346'
ExplodingCabbage Nov 27, 2023
eaa77ac
Merge commit '13e178a3abcdc1acfb3dd63aecc2f5e22b7772ae'
ExplodingCabbage Nov 27, 2023
048051d
Merge commit '8816889a7d69f466e0370f6065fd67a3fc6a2ee1'
ExplodingCabbage Nov 27, 2023
3217836
Merge commit '294c0cc9c5a0a5f127dd12ab2cc7ac7ca9c3e59c'
ExplodingCabbage Nov 27, 2023
a1dd1fa
Merge commit '1d637e4bf05e6cdbd7edb15b891c59dbb9796991'
ExplodingCabbage Nov 27, 2023
4919887
Merge commit 'aedfa0b912a62aa509fa995f09d11a46641a13f5'
ExplodingCabbage Nov 27, 2023
804464d
Merge commit '971c4a2e2116f191865bb1c0578862641165a3e6'
ExplodingCabbage Nov 27, 2023
452c311
Merge commit '7cfa476187a6e08090a1d83b7ffeee9599c7e1d4'
ExplodingCabbage Nov 27, 2023
6c9f853
Merge commit 'bcca758d13ef466a7ae13f4d9d99689ba0043640'
ExplodingCabbage Nov 27, 2023
67aa728
Merge commit 'eadc241e078b2111b4190efc7968f3a3764126d6'
ExplodingCabbage Nov 27, 2023
a866f86
Merge commit '22c208ac1ced1b7fac3d4314f45bfaa159d672dc'
ExplodingCabbage Nov 27, 2023
7de915c
Merge commit '09025b97b34d9694d43a40f16a7641ff7e91ba36'
ExplodingCabbage Nov 27, 2023
f0380cb
Merge commit 'd7b02f9d02f49b019b68da5a0f8b5e3859cf6c04'
ExplodingCabbage Nov 27, 2023
c84e279
Merge commit '42dcc024c4f79fdea81cf703b9df7623c0205c42'
ExplodingCabbage Nov 27, 2023
7c6308a
Merge commit '95d8b83c6ce63ee9b1aa8a03e3cac93138fd1840'
ExplodingCabbage Nov 27, 2023
4a69c19
Merge commit 'a91debf19e0ee9cf3049242b2b7c35273b7711f6'
ExplodingCabbage Nov 27, 2023
2adb726
Merge commit 'e5cb726e39686ba5c4b0758fb1cb37c6f1ce1dc9'
ExplodingCabbage Nov 27, 2023
441449f
Merge commit '67849fde29eb749a8d3cc4f140c584238779325e'
ExplodingCabbage Nov 27, 2023
2b4a4b7
Merge commit '145c4183dc28e8f9d111231a59b13c19f0806db1'
ExplodingCabbage Nov 27, 2023
596916b
Merge commit '13cbd1b5722587607ddbda3105cad2c24a0baae3'
ExplodingCabbage Nov 27, 2023
bfdb4d4
Merge commit '9faca127acf73e2a4586de8700f46bacf832ff52'
ExplodingCabbage Nov 27, 2023
524a87e
Merge commit 'b3837cc70ca644c78992accb659a7d0132334255'
ExplodingCabbage Nov 27, 2023
71b1c2f
Merge commit '3d63e222dc8f41709cd3562ae264a3f478abf0f4'
ExplodingCabbage Nov 27, 2023
14a8290
Merge commit 'fbf2e613a5b38a1fd4ca65062c9fb8f1dd924bd4'
ExplodingCabbage Nov 27, 2023
63411db
Merge commit 'b6a28a26f2ef97fd15ff8a2adea1958762d27f75'
ExplodingCabbage Nov 27, 2023
da12dec
Merge commit 'd2fb96844cbe4cf728a3482d1f26d9d7baa9ff96'
ExplodingCabbage Nov 27, 2023
3b51a9c
Merge commit '4347d35fe4afad6ca6e7b8b2b0bb545dfbc711b9'
ExplodingCabbage Nov 27, 2023
888a9cc
Merge commit '6c4b368584325062def254e4280c805690b40faa'
ExplodingCabbage Nov 27, 2023
e498e92
Merge commit '8fc7f44ecdfdb0f6b006f6dfbaa22af556a4d974'
ExplodingCabbage Nov 27, 2023
e8cd845
Merge commit 'd5583dd2918809d5bcf92b24620c4327b345e0af'
ExplodingCabbage Nov 27, 2023
3df3bbf
Merge commit '5eb852bb789a5915de2dc9fe8e4217a18e7d3482'
ExplodingCabbage Nov 27, 2023
9b108f9
Merge remote-tracking branch 'pygithub/main'
ExplodingCabbage Nov 27, 2023
3323aee
Add missing urllib.parse.quote calls in AuthenticatedUser.py
ExplodingCabbage Nov 27, 2023
08ba61a
Add missing urllib.parse.quote calls in Enterprise.py
ExplodingCabbage Nov 27, 2023
1e0516f
Add urllib.parse.quote calls to GithubIntegration.py
ExplodingCabbage Nov 27, 2023
e78064c
Add urllib.parse.quote calls to MainClass.py
ExplodingCabbage Nov 27, 2023
9d5c39d
Add urllib.parse.quote calls to NamedUser.py
ExplodingCabbage Nov 27, 2023
eba285a
Add urllib.parse.quote calls to Organization.py
ExplodingCabbage Nov 27, 2023
4a09394
Add urllib.parse.quote calls to Repository.py
ExplodingCabbage Nov 27, 2023
c1f33d3
Add urllib.parse.quote calls to Team.py
ExplodingCabbage Nov 27, 2023
a1d8312
Update URL in replay data to reflect changes
ExplodingCabbage Nov 27, 2023
5eb0e0a
Merge branch 'main' into master
EnricoMi Dec 12, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions github/AuthenticatedUser.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
################################################################################
from __future__ import annotations

import urllib.parse
from datetime import datetime, timezone
from typing import TYPE_CHECKING, Any, NamedTuple

Expand Down Expand Up @@ -810,6 +811,7 @@ def get_repo(self, name: str) -> Repository:
:calls: `GET /repos/{owner}/{repo} <http://docs.github.com/en/rest/reference/repos>`_
"""
assert isinstance(name, str), name
name = urllib.parse.quote(name)
headers, data = self._requester.requestJsonAndCheck("GET", f"/repos/{self.login}/{name}")
return github.Repository.Repository(self._requester, headers, data, completed=True)

Expand Down Expand Up @@ -1032,6 +1034,7 @@ def get_organization_membership(self, org: str) -> Membership:
:calls: `GET /user/memberships/orgs/{org} <https://docs.github.com/en/rest/reference/orgs#get-an-organization-membership-for-the-authenticated-user>`_
"""
assert isinstance(org, str)
org = urllib.parse.quote(org)
headers, data = self._requester.requestJsonAndCheck("GET", f"/user/memberships/orgs/{org}")
return github.Membership.Membership(self._requester, headers, data, completed=True)

Expand Down
2 changes: 2 additions & 0 deletions github/Enterprise.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# along with PyGithub. If not, see <http://www.gnu.org/licenses/>. #
# #
################################################################################
import urllib.parse
from typing import Any, Dict

from github.EnterpriseConsumedLicenses import EnterpriseConsumedLicenses
Expand All @@ -37,6 +38,7 @@ def __init__(
requester: Requester,
enterprise: str,
):
enterprise = urllib.parse.quote(enterprise)
super().__init__(requester, {}, {"enterprise": enterprise, "url": f"/enterprises/{enterprise}"}, True)

def _initAttributes(self) -> None:
Expand Down
7 changes: 7 additions & 0 deletions github/GithubIntegration.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import urllib.parse
import warnings
from typing import Any

Expand Down Expand Up @@ -216,6 +217,8 @@ def get_installation(self, owner: str, repo: str) -> Installation:

:calls: `GET /repos/{owner}/{repo}/installation <https://docs.github.com/en/rest/reference/apps#get-a-repository-installation-for-the-authenticated-app>`
"""
owner = urllib.parse.quote(owner)
repo = urllib.parse.quote(repo)
return self._get_installed_app(url=f"/repos/{owner}/{repo}/installation")

def get_installations(self) -> PaginatedList[Installation]:
Expand All @@ -235,18 +238,22 @@ def get_org_installation(self, org: str) -> Installation:
"""
:calls: `GET /orgs/{org}/installation <https://docs.github.com/en/rest/apps/apps#get-an-organization-installation-for-the-authenticated-app>`
"""
org = urllib.parse.quote(org)
return self._get_installed_app(url=f"/orgs/{org}/installation")

def get_repo_installation(self, owner: str, repo: str) -> Installation:
"""
:calls: `GET /repos/{owner}/{repo}/installation <https://docs.github.com/en/rest/reference/apps#get-a-repository-installation-for-the-authenticated-app>`
"""
owner = urllib.parse.quote(owner)
repo = urllib.parse.quote(repo)
return self._get_installed_app(url=f"/repos/{owner}/{repo}/installation")

def get_user_installation(self, username: str) -> Installation:
"""
:calls: `GET /users/{username}/installation <https://docs.github.com/en/rest/apps/apps#get-a-user-installation-for-the-authenticated-app>`
"""
username = urllib.parse.quote(username)
return self._get_installed_app(url=f"/users/{username}/installation")

def get_app_installation(self, installation_id: int) -> Installation:
Expand Down
12 changes: 10 additions & 2 deletions github/MainClass.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
from __future__ import annotations

import pickle
import urllib.parse
import warnings
from datetime import datetime
from typing import TYPE_CHECKING, Any, BinaryIO, TypeVar
Expand Down Expand Up @@ -321,6 +322,7 @@ def get_license(self, key: Opt[str] = NotSet) -> License:
"""

assert isinstance(key, str), key
key = urllib.parse.quote(key)
headers, data = self.__requester.requestJsonAndCheck("GET", f"/licenses/{key}")
return github.License.License(self.__requester, headers, data, completed=True)

Expand All @@ -344,10 +346,11 @@ def get_user(self, login: Opt[str] = NotSet) -> NamedUser | AuthenticatedUser:
"""
:calls: `GET /users/{user} <https://docs.github.com/en/rest/reference/users>`_ or `GET /user <https://docs.github.com/en/rest/reference/users>`_
"""
assert login is NotSet or isinstance(login, str), login
if login is NotSet:
return github.AuthenticatedUser.AuthenticatedUser(self.__requester, {}, {"url": "/user"}, completed=False)
else:
assert isinstance(login, str), login
login = urllib.parse.quote(login)
headers, data = self.__requester.requestJsonAndCheck("GET", f"/users/{login}")
return github.NamedUser.NamedUser(self.__requester, headers, data, completed=True)

Expand Down Expand Up @@ -376,6 +379,7 @@ def get_organization(self, login: str) -> Organization:
:calls: `GET /orgs/{org} <https://docs.github.com/en/rest/reference/orgs>`_
"""
assert isinstance(login, str), login
login = urllib.parse.quote(login)
headers, data = self.__requester.requestJsonAndCheck("GET", f"/orgs/{login}")
return github.Organization.Organization(self.__requester, headers, data, completed=True)

Expand Down Expand Up @@ -487,6 +491,7 @@ def get_global_advisory(self, ghsa_id: str) -> GlobalAdvisory:
:rtype: :class:`github.GlobalAdvisory.GlobalAdvisory`
"""
assert isinstance(ghsa_id, str), ghsa_id
ghsa_id = urllib.parse.quote(ghsa_id)
headers, data = self.__requester.requestJsonAndCheck("GET", f"/advisories/{ghsa_id}")
return github.GlobalAdvisory.GlobalAdvisory(self.__requester, headers, data, completed=True)

Expand Down Expand Up @@ -847,6 +852,7 @@ def get_hook(self, name: str) -> HookDescription:
:calls: `GET /hooks/{name} <https://docs.github.com/en/rest/reference/repos#webhooks>`_
"""
assert isinstance(name, str), name
name = urllib.parse.quote(name)
headers, attributes = self.__requester.requestJsonAndCheck("GET", f"/hooks/{name}")
return HookDescription(self.__requester, headers, attributes, completed=True)

Expand Down Expand Up @@ -892,6 +898,7 @@ def get_gitignore_template(self, name: str) -> GitignoreTemplate:
:calls: `GET /gitignore/templates/{name} <https://docs.github.com/en/rest/reference/gitignore>`_
"""
assert isinstance(name, str), name
name = urllib.parse.quote(name)
headers, attributes = self.__requester.requestJsonAndCheck("GET", f"/gitignore/templates/{name}")
return github.GitignoreTemplate.GitignoreTemplate(self.__requester, headers, attributes, completed=True)

Expand Down Expand Up @@ -953,7 +960,6 @@ def get_app(self, slug: Opt[str] = NotSet) -> GithubApp:
"""
:calls: `GET /apps/{slug} <https://docs.github.com/en/rest/reference/apps>`_ or `GET /app <https://docs.github.com/en/rest/reference/apps>`_
"""
assert slug is NotSet or isinstance(slug, str), slug

if slug is NotSet:
# with no slug given, calling /app returns the authenticated app,
Expand All @@ -965,5 +971,7 @@ def get_app(self, slug: Opt[str] = NotSet) -> GithubApp:
)
return GithubIntegration(**self.__requester.kwargs).get_app()
else:
assert isinstance(slug, str), slug
# with a slug given, we can lazily load the GithubApp
slug = urllib.parse.quote(slug)
return github.GithubApp.GithubApp(self.__requester, {}, {"url": f"/apps/{slug}"}, completed=False)
2 changes: 2 additions & 0 deletions github/Migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
################################################################################
from __future__ import annotations

import urllib.parse
from datetime import datetime
from typing import Any

Expand Down Expand Up @@ -145,6 +146,7 @@ def unlock_repo(self, repo_name: str) -> None:
:calls: `DELETE /user/migrations/{migration_id}/repos/{repo_name}/lock <https://docs.github.com/en/rest/reference/migrations>`_
"""
assert isinstance(repo_name, str), repo_name
repo_name = urllib.parse.quote(repo_name)
headers, data = self._requester.requestJsonAndCheck(
"DELETE",
f"{self.url}/repos/{repo_name}/lock",
Expand Down
2 changes: 2 additions & 0 deletions github/NamedUser.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
################################################################################
from __future__ import annotations

import urllib.parse
from datetime import datetime
from typing import TYPE_CHECKING, Any

Expand Down Expand Up @@ -514,6 +515,7 @@ def get_organization_membership(self, org: str | Organization) -> Membership:
assert isinstance(org, str) or isinstance(org, github.Organization.Organization), org
if isinstance(org, github.Organization.Organization):
org = org.login # type: ignore
org = urllib.parse.quote(org)
headers, data = self._requester.requestJsonAndCheck("GET", f"/orgs/{org}/memberships/{self.login}")
return github.Membership.Membership(self._requester, headers, data, completed=True)

Expand Down
17 changes: 11 additions & 6 deletions github/Organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
################################################################################
from __future__ import annotations

import urllib.parse
from datetime import datetime
from typing import TYPE_CHECKING, Any

Expand Down Expand Up @@ -527,16 +528,18 @@ def create_secret(
if is_defined(selected_repositories):
put_parameters["selected_repository_ids"] = [element.id for element in selected_repositories]

self._requester.requestJsonAndCheck("PUT", f"{self.url}/actions/secrets/{secret_name}", input=put_parameters)
self._requester.requestJsonAndCheck(
"PUT", f"{self.url}/actions/secrets/{urllib.parse.quote(secret_name)}", input=put_parameters
)

return github.OrganizationSecret.OrganizationSecret(
requester=self._requester,
headers={},
attributes={
"name": secret_name,
"visibility": visibility,
"selected_repositories_url": f"{self.url}/actions/secrets/{secret_name}/repositories",
"url": f"{self.url}/actions/secrets/{secret_name}",
"selected_repositories_url": f"{self.url}/actions/secrets/{urllib.parse.quote(secret_name)}/repositories",
"url": f"{self.url}/actions/secrets/{urllib.parse.quote(secret_name)}",
},
completed=False,
)
Expand Down Expand Up @@ -564,7 +567,7 @@ def get_secret(self, secret_name: str) -> OrganizationSecret:
return github.OrganizationSecret.OrganizationSecret(
requester=self._requester,
headers={},
attributes={"url": f"{self.url}/actions/secrets/{secret_name}"},
attributes={"url": f"{self.url}/actions/secrets/{urllib.parse.quote(secret_name)}"},
completed=False,
)

Expand Down Expand Up @@ -640,7 +643,7 @@ def create_variable(
"name": variable_name,
"visibility": visibility,
"value": value,
"selected_repositories_url": f"{self.url}/actions/variables/{variable_name}/repositories",
"selected_repositories_url": f"{self.url}/actions/variables/{urllib.parse.quote(variable_name)}/repositories",
"url": self.url,
},
completed=False,
Expand Down Expand Up @@ -669,7 +672,7 @@ def get_variable(self, variable_name: str) -> OrganizationVariable:
return github.OrganizationVariable.OrganizationVariable(
requester=self._requester,
headers={},
attributes={"url": f"{self.url}/actions/variables/{variable_name}"},
attributes={"url": f"{self.url}/actions/variables/{urllib.parse.quote(variable_name)}"},
completed=False,
)

Expand Down Expand Up @@ -922,6 +925,7 @@ def get_repo(self, name: str) -> Repository:
:rtype: :class:`github.Repository.Repository`
"""
assert isinstance(name, str), name
name = urllib.parse.quote(name)
headers, data = self._requester.requestJsonAndCheck(
"GET",
f"/repos/{self.login}/{name}",
Expand Down Expand Up @@ -968,6 +972,7 @@ def get_team_by_slug(self, slug: str) -> Team:
:calls: `GET /orgs/{org}/teams/{team_slug} <https://docs.github.com/en/rest/reference/teams#get-a-team-by-name>`_
"""
assert isinstance(slug, str), slug
slug = urllib.parse.quote(slug)
headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/teams/{slug}")
return github.Team.Team(self._requester, headers, data, completed=True)

Expand Down