Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: handle tags like debian/2%2.6-21 as identifiers#1336

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

emanueleaina
Copy link
Contributor

@emanueleainaemanueleaina commentedFeb 26, 2021
edited
Loading

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 likedebian/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 thedebian/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 sees 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.

I've run the unit tests but not the integration ones, so in theory this does
not break anything but I can't really confirm it. All I can firmly say is that it
fixes the issue I hit. :D

nejch reacted with thumbs up emoji
@@ -55,15 +55,15 @@ def copy_dict(dest: Dict[str, Any], src: Dict[str, Any]) -> None:
dest[k] = v


def clean_str_id(id: str) -> str:
return id.replace("/", "%2F").replace("#", "%23")
def clean_str_id(id):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Can the type-hints not be removed?

max-wittig and emanueleaina reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Uuuuh, absolutely yes, sorry. Fixing it now!

@JohnVillalovos
Copy link
Member

Overall looks good to me. Please put the type-hints back in. Also change "fix: Handle..." to "fix: handle" to fix the lint issue.

Thanks.

nejch, max-wittig, and emanueleaina reacted with thumbs up emoji

@emanueleainaemanueleainaforce-pushed thefix/quote-everything branch 2 times, most recently fromf213a90 to41dc7bfCompareMarch 5, 2021 00:02
@codecov-io
Copy link

codecov-io commentedMar 5, 2021
edited
Loading

Codecov Report

Merging#1336 (b4dac5c) intomaster (aa13214) willnot change coverage.
The diff coverage is100.00%.

Impacted file tree graph

@@           Coverage Diff           @@##           master    #1336   +/-   ##=======================================  Coverage   80.21%   80.21%           =======================================  Files          73       73             Lines        3801     3801           =======================================  Hits         3049     3049             Misses        752      752
FlagCoverage Δ
unit80.21% <100.00%> (ø)

Flags with carried forward coverage won't be shown.Click here to find out more.

Impacted FilesCoverage Δ
gitlab/utils.py71.42% <100.00%> (ø)

Continue to review full report at Codecov.

Legend -Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing data
Powered byCodecov. Last updateaa13214...b4dac5c. Read thecomment docs.

Git refnames are relatively free-form and can contain all sort forspecial characters, not just `/` and `#`, seehttp://git-scm.com/docs/git-check-ref-formatIn particular, Debian's DEP-14 standard for storing packaging in gitrepositories mandates the use of the `%` character in tags in somecases like `debian/2%2.6-21`.Unfortunately python-gitlab currently only escapes `/` to `%2F` and insome cases `#` to `%23`. This means that when using the commit API toretrieve information about the `debian/2%2.6-21` tag only the slash isescaped before being inserted in the URL path and the `%` is leftuntouched, resulting in something like`/api/v4/projects/123/repository/commits/debian%2F2%2.6-21`. Whenurllib3 seees that it detects the invalid `%` escape and then urlencodesthe whole string, resulting in`/api/v4/projects/123/repository/commits/debian%252F2%252.6-21`, wherethe original `/` got escaped twice and produced `%252F`.To avoid the issue, fully urlencode identifiers and parameters to avoidthe urllib3 auto-escaping in all cases.Signed-off-by: Emanuele Aina <emanuele.aina@collabora.com>
@emanueleainaemanueleaina changed the titlefix: Handle tags like debian/2%2.6-21 as identifiersfix: handle tags like debian/2%2.6-21 as identifiersMar 5, 2021
Copy link
Member

@nejchnejch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thanks @em-! I'm now questioning why there was any custom URL encoding in the first place, but I've opened a follow-up in#1356 :)

@nejchnejch merged commit48fc907 intopython-gitlab:masterMar 6, 2021
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@JohnVillalovosJohnVillalovosJohnVillalovos approved these changes

@nejchnejchnejch approved these changes

Assignees

@emanueleainaemanueleaina

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@emanueleaina@JohnVillalovos@codecov-io@nejch

[8]ページ先頭

©2009-2025 Movatter.jp