summaryrefslogtreecommitdiff
path: root/gitlab/utils.py
Commit message (Collapse)AuthorAgeFilesLines
* chore: replace usage of utils._url_encode() with utils.EncodedId()jlvillal/encoded_idJohn L. Villalovos2022-01-131-75/+10
| | | | | | utils.EncodedId() has basically the same functionalityy of using utils._url_encode(). So remove utils._url_encode() as we don't need it.
* chore: add EncodedId string class to use to hold URL-encoded pathsJohn L. Villalovos2022-01-131-4/+64
| | | | | | | | | Add EncodedId string class. This class returns a URL-encoded string but ensures it will only URL-encode it once even if recursively called. Also added some functional tests of 'lazy' objects to make sure they work.
* fix: use url-encoded ID in all pathsJohn L. Villalovos2022-01-131-1/+13
| | | | | | | | | | | | Make sure all usage of the ID in the URL path is encoded. Normally it isn't an issue as most IDs are integers or strings which don't contain a slash ('/'). But when the ID is a string with a slash character it will break things. Add a test case that shows this fixes wikis issue with subpages which use the slash character. Closes: #1079
* fix: remove custom URL encodingJohn L. Villalovos2022-01-081-3/+20
| | | | | | | | | | We were using `str.replace()` calls to take care of URL encoding issues. Switch them to use our `utils._url_encode()` function which itself uses `urllib.parse.quote()` Closes: #1356
* fix: stop encoding '.' to '%2E'jlvillal/leave_dotJohn L. Villalovos2021-12-201-7/+1
| | | | | | | | | | | | | | | | | | | | 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.
* refactor: use f-strings for string formattingNejc Habjan2021-11-051-1/+1
|
* chore: remove unused function sanitize_parameters()John L. Villalovos2021-04-181-8/+0
| | | | | | The function sanitize_parameters() was used when the v3 API was in use. Since v3 API support has been removed there are no more users of this function.
* fix: handle tags like debian/2%2.6-21 as identifiersEmanuele Aina2021-03-051-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | Git refnames are relatively free-form and can contain all sort for special characters, not just `/` and `#`, see http://git-scm.com/docs/git-check-ref-format In particular, Debian's DEP-14 standard for storing packaging in git repositories mandates the use of the `%` character in tags in some cases like `debian/2%2.6-21`. Unfortunately python-gitlab currently only escapes `/` to `%2F` and in some cases `#` to `%23`. This means that when using the commit API to retrieve information about the `debian/2%2.6-21` tag only the slash is escaped before being inserted in the URL path and the `%` is left untouched, resulting in something like `/api/v4/projects/123/repository/commits/debian%2F2%2.6-21`. When urllib3 seees that it detects the invalid `%` escape and then urlencodes the whole string, resulting in `/api/v4/projects/123/repository/commits/debian%252F2%252.6-21`, where the original `/` got escaped twice and produced `%252F`. To avoid the issue, fully urlencode identifiers and parameters to avoid the urllib3 auto-escaping in all cases. Signed-off-by: Emanuele Aina <emanuele.aina@collabora.com>
* chore: disallow incomplete type defsJohn L. Villalovos2021-02-281-2/+3
| | | | | | | | | | Don't allow a partially annotated function definition. Either none of the function is annotated or all of it must be. Update code to ensure no-more partially annotated functions. Update gitlab/cli.py with better type-hints. Changed Tuple[Any, ...] to Tuple[str, ...]
* chore: add type hints to gitlab/utils.pyJohn L. Villalovos2021-02-251-6/+14
|
* refactor: split unit tests by GitLab API resourcesNejc Habjan2020-08-221-0/+8
|
* fix: remove null values from features POST data, because it failsMateusz Filipowicz2020-02-071-0/+4
| | | | with HTTP 500
* refactor: remove six dependencyMax Wittig2019-12-181-2/+2
|
* fix: convert # to %23 in URLsfix/779Gauvain Pocentek2019-06-081-0/+4
| | | | | | Refactor a bit to handle this change, and add unit tests. Closes #779
* refactor: format everything blackrefactor/blackMax Wittig2019-05-161-2/+2
|
* Raise an exception on https redirects for PUT/POSTGauvain Pocentek2018-08-241-0/+20
| | | | | | | | | | | POST and PUT requests are modified by clients when redirections happen. A common problem with python-gitlab is a misconfiguration of the server URL: the http to https redirection breaks some requests. With this change python-gitlab should detect problematic redirections, and raise a proper exception instead of failing with a cryptic error. Closes #565
* update copyright yearsGauvain Pocentek2017-05-241-1/+1
|
* fix pep8 testGauvain Pocentek2016-08-111-0/+1
|
* Add copyright header to utils.pyGauvain Pocentek2016-08-111-0/+17
|
* Allow to stream the downloads when appropriateGauvain Pocentek2016-07-171-0/+15
Some API calls will download possibly large data, resulting in a high memory usage and out-of-memory errors. For these API calls use the requests streaming capabilities and download chunked data. The caller is responsible of providing a callable to actually store the data. The default callable just prints the data on stdout.