Show More
@@ -819,15 +819,16 def archive(web, req, tmpl): | |||
|
819 | 819 | |
|
820 | 820 | ctx = webutil.changectx(web.repo, req) |
|
821 | 821 | pats = [] |
|
822 | matchfn = None | |
|
822 | 823 | file = req.form.get('file', None) |
|
823 | 824 | if file: |
|
824 |
|
|
|
825 | patandfile = file.split(':') | |
|
826 | if len(patandfile) > 1 and patandfile[0].lower() in ('glob', 'relglob', | |
|
827 | 'path', 'relpath', 're', 'relre', 'set'): | |
|
828 | msg = 'Archive pattern not allowed: %s' % file | |
|
829 |
raise ErrorResponse(HTTP_ |
|
|
830 | pats = ['path:' + file] | |
|
825 | pats = ['path:' + file[0]] | |
|
826 | matchfn = scmutil.match(ctx, pats, default='path') | |
|
827 | if pats: | |
|
828 | files = [f for f in ctx.manifest().keys() if matchfn(f)] | |
|
829 | if not files: | |
|
830 | raise ErrorResponse(HTTP_NOT_FOUND, | |
|
831 | 'file(s) not found: %s' % file[0]) | |
|
831 | 832 | |
|
832 | 833 | mimetype, artype, extension, encoding = web.archive_specs[type_] |
|
833 | 834 | headers = [ |
@@ -838,7 +839,6 def archive(web, req, tmpl): | |||
|
838 | 839 | req.headers.extend(headers) |
|
839 | 840 | req.respond(HTTP_OK, mimetype) |
|
840 | 841 | |
|
841 | matchfn = scmutil.match(ctx, pats, default='path') | |
|
842 | 842 | archival.archive(web.repo, req, cnode, artype, prefix=name, |
|
843 | 843 | matchfn=matchfn, |
|
844 | 844 | subrepos=web.configbool("web", "archivesubrepos")) |
@@ -108,10 +108,15 test that we can download single directo | |||
|
108 | 108 | $ python getarchive.py "$TIP" gz foo | gunzip | tar tf - 2>/dev/null |
|
109 | 109 | test-archive-2c0277f05ed4/foo |
|
110 | 110 | |
|
111 | test that we detect file patterns that match no files | |
|
112 | ||
|
113 | $ python getarchive.py "$TIP" gz foobar | |
|
114 | HTTP Error 404: file(s) not found: foobar | |
|
115 | ||
|
111 | 116 | test that we reject unsafe patterns |
|
112 | 117 | |
|
113 | 118 | $ python getarchive.py "$TIP" gz relre:baz |
|
114 |
HTTP Error 40 |
|
|
119 | HTTP Error 404: file(s) not found: relre:baz | |
|
115 | 120 | |
|
116 | 121 | $ "$TESTDIR/killdaemons.py" $DAEMON_PIDS |
|
117 | 122 |
General Comments 0
You need to be logged in to leave comments.
Login now