summaryrefslogtreecommitdiff
path: root/gitlab
diff options
context:
space:
mode:
authorJohn L. Villalovos <john@sodarock.com>2021-12-20 14:24:17 -0800
committerJohn L. Villalovos <john@sodarock.com>2021-12-20 14:24:17 -0800
commit702e41dd0674e76b292d9ea4f559c86f0a99edfe (patch)
tree7af846efbabb09e7941d599503ae658f37dea6f7 /gitlab
parentccefe80f150eb50176e52b8c9f5b4d0bdb4f5b43 (diff)
downloadgitlab-jlvillal/leave_dot.tar.gz
fix: stop encoding '.' to '%2E'jlvillal/leave_dot
Forcing the encoding of '.' to '%2E' causes issues. It also goes against the RFC: https://datatracker.ietf.org/doc/html/rfc3986.html#section-2.3 From the RFC: For consistency, percent-encoded octets in the ranges of ALPHA (%41-%5A and %61-%7A), DIGIT (%30-%39), hyphen (%2D), period (%2E), underscore (%5F), or tilde (%7E) should not be created by URI producers... Closes #1006 Related #1356 Related #1561 BREAKING CHANGE: stop encoding '.' to '%2E'. This could potentially be a breaking change for users who have incorrectly configured GitLab servers which don't handle period '.' characters correctly.
Diffstat (limited to 'gitlab')
-rw-r--r--gitlab/client.py27
-rw-r--r--gitlab/utils.py8
2 files changed, 12 insertions, 23 deletions
diff --git a/gitlab/client.py b/gitlab/client.py
index d3fdaab..e61fb97 100644
--- a/gitlab/client.py
+++ b/gitlab/client.py
@@ -593,24 +593,19 @@ class Gitlab(object):
json, data, content_type = self._prepare_send_data(files, post_data, raw)
opts["headers"]["Content-type"] = content_type
- # Requests assumes that `.` should not be encoded as %2E and will make
- # changes to urls using this encoding. Using a prepped request we can
- # get the desired behavior.
- # The Requests behavior is right but it seems that web servers don't
- # always agree with this decision (this is the case with a default
- # gitlab installation)
- req = requests.Request(verb, url, json=json, data=data, params=params, **opts)
- prepped = self.session.prepare_request(req)
- if TYPE_CHECKING:
- assert prepped.url is not None
- prepped.url = utils.sanitized_url(prepped.url)
- settings = self.session.merge_environment_settings(
- prepped.url, {}, streamed, verify, None
- )
-
cur_retries = 0
while True:
- result = self.session.send(prepped, timeout=timeout, **settings)
+ result = self.session.request(
+ method=verb,
+ url=url,
+ json=json,
+ data=data,
+ params=params,
+ timeout=timeout,
+ verify=verify,
+ stream=streamed,
+ **opts,
+ )
self._check_redirects(result)
diff --git a/gitlab/utils.py b/gitlab/utils.py
index 220a8c9..a1dcb45 100644
--- a/gitlab/utils.py
+++ b/gitlab/utils.py
@@ -16,7 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from typing import Any, Callable, Dict, Optional
-from urllib.parse import quote, urlparse
+from urllib.parse import quote
import requests
@@ -60,11 +60,5 @@ def clean_str_id(id: str) -> str:
return quote(id, safe="")
-def sanitized_url(url: str) -> str:
- parsed = urlparse(url)
- new_path = parsed.path.replace(".", "%2E")
- return parsed._replace(path=new_path).geturl()
-
-
def remove_none_from_dict(data: Dict[str, Any]) -> Dict[str, Any]:
return {k: v for k, v in data.items() if v is not None}