Giter Club home page Giter Club logo

Comments (8)

sethmlarson avatar sethmlarson commented on July 17, 2024 2

BTW you're probably getting different behavior on macOS versus Linux because the two have different versions of urllib3. urllib3's URL parser is used with the context of an HTTP client so it optimizes for sending over the wire, not parsing URLs and passing them to application contexts (ie doesn't do the hex decoding)

from artifactory.

calvinpark avatar calvinpark commented on July 17, 2024

% in file name breaks both Mac and Linux. These characters are important for Debian packages such as libgcc1_1%3a8.3.0-6ubuntu1~18.04.1_amd64.deb

from artifactory.

calvinpark avatar calvinpark commented on July 17, 2024

relative_to function may be related https://github.com/devopshq/artifactory/blob/develop/artifactory.py#L759

from artifactory.

calvinpark avatar calvinpark commented on July 17, 2024

Found the problem with % on drv = part.split(url.path)[0]

url.path comes from urllib3.util.parse_url() which calls urllib3.util._encode_invalid_chars() which has IMO a bug that changes all percent-encoded bytes to upper case

# Normalize existing percent-encoded bytes.
for enc in percent_encodings:
    if not enc.isupper():
        component = component.replace(enc, enc.upper())

This modifies the URL's casing, and part-shuffling fails.
Opened an issue urllib3.util._encode_invalid_chars() changes the percent-encoded bytes to upper case #1677

from artifactory.

calvinpark avatar calvinpark commented on July 17, 2024

Same rc is also causing URLs with ~ to fail. During drv = part.split(url.path)[0], url.path is url-encoded while part is not.

387  ->	                drv = part.split(url.path)[0]
388  	                path_parts = url.path.strip(sep).split(sep)
389  	                root = sep + path_parts[0] + sep
390  	                rest = sep.join(path_parts[1:])
391  	                return drv, root, rest
(Pdb) url.path
'/something/something/containerd.io_1.2.0%7Erc.0-1_amd64.deb'
(Pdb) part
'https://domain.com/something/something/containerd.io_1.2.0~rc.0-1_amd64.deb'

In order for drv = part.split(url.path)[0] to work, either part must be encoded or url.path must be decoded.

Now, there seems to be a fight online about whether tilde should be encoded or not. I guess Linux version of urllib3 encodes it whereas Mac version of urllib3 does not? Since the dependent packages are yielding inconsistent results, I think ArtifactoryPath should program defensively and expect either cases.

from artifactory.

calvinpark avatar calvinpark commented on July 17, 2024

Welp that was fast. The issue i opened was closed within 8 hours as a "feature not a bug". Regardless, I think ArtifactoryPath should keep the original casing of percent-encoded bytes because otherwise the copy flat out fails mysteriously. A lowercase hex after an @ is a valid file name after all.

from artifactory.

calvinpark avatar calvinpark commented on July 17, 2024

Not sure what the best way to unquote the URL is. I'm writing something like

def _get_path(part, path):
    if path in part:
        return path

    unquoted_path = urllib3.parse.unquote(path)
    if unquoted_path in part:
        return unquoted_path
    else:
        raise ValueError(f"{part} does not include {path}")

but it seems that urllib3 does not have parse.unquote() which its counterpart urllib does. It seems silly to import urllib just to call unquote. Thinking...

from artifactory.

vasokot avatar vasokot commented on July 17, 2024

ubuntu 16.04 - All work correctly

>>> from artifactory import ArtifactoryPath
>>> target = ArtifactoryPath("https://artfactory/repo/tmp", auth=('user', 'password'))
>>> target.deploy_file('file~with~tilde')
>>> origin = ArtifactoryPath("https://artfactory/repo/tmp/file~with~tilde", auth=('user', 'password'))
>>> target = ArtifactoryPath("https://artfactory/repo/tmp/file~with~tilde2", auth=('user', 'password'))
>>> origin.copy(target)
>>> target_two = ArtifactoryPath("https://artfactory/repo/tmp/file~with~tilde~two", auth=('user', 'password'))
>>> origin.copy(target_two)

from artifactory.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.