Archive download and special characters

I see that an archive of a commit can be HTTP GET at http://<server>/<repo>/archive/<commit_id>.zip.
With a Mercurial repo, I see that we can use the name of a branch or tag instead of the commit_id.

This is great!

Now my problem is that our convention is to prefix the names of our feature branches with f/, like in f/my-feature. Obviously if I want to use this branch name in the url, I have to escape the slash in some way. Is there any way to do it?

I tried to escape it using %2F (http://<server>/<repo>/archive/f%2Fmy-feature.zip) but it does not work:

  • With the Apache config AllowEncodedSlashes set to Off, it gives an Apache 404
  • With AllowEncodedSlashes set to On, it gives a RhodeCode 404
  • With AllowEncodedSlashes set to NoDecode, it gives the text “Unknown commit_id f%2Fmy-feature”

Hmm, actually i think this might be a bug.

if you would see that matching pattern: https://code.rhodecode.com/rhodecode-enterprise-ce/files/c75dd264c5f748c55e73391632ccd00a07f03f99/rhodecode/apps/repository/init.py#L93

This wouldn’t catch f/feature-1 name for example. I think we need to change it to:

    config.add_route(
        name='repo_archivefile',
        pattern='/{repo_name:.*?[^/]}/archive/{fname:.*}', repo_route=True)

Like in other places that match a path or names with /

When I apply this change, there is indeed one Apache configuration that makes it work: AllowEncodedSlashes On. The other values behave the same as before.

Quick follow up: from the source code it seems that we should be able to download a .zip, a .tgz or a .tbz2. Only the .zip works for me, is there a configuration to enable the other two?

Thanks

Other formats are available with the following extensions:

.tar.bz2
.tar.gz
1 Like