# HG changeset patch # User Steve Barnes (Home) # Date 1420130441 0 # Node ID 9d58ca6253a3f48b4767e1e4a6a17f04df1a3fb7 # Parent 554eaa682561af9dc31826cfbcb0ee564d0dfc6d Added check for excessive .. entries which would go out of domain. This addresses possible problems with too many .. entries i.e. if the repo root is http://www.xample.org/repo/proj1 then ^/../proj2 is fine as is ^/../../repo2/p1 but ^/../../../www./Local is not as it doesn't make sense to have relative references that go to a different site. diff --git a/hgsubversion/svnexternals.py b/hgsubversion/svnexternals.py --- a/hgsubversion/svnexternals.py +++ b/hgsubversion/svnexternals.py @@ -121,14 +121,20 @@ class RelativeSourceError(Exception): pass def resolvedots(url): - """ Fix references that include .. entries.""" + """ + Fix references that include .. entries. + Scans a URL for .. type entries and resolves them but will not allow any + number of ..s to take us out of domain so http://.. will raise an exception. + """ orig = url.split('/') fixed = [] for item in orig: if item != '..': fixed.append(item) - else: + elif len(fixed) > 2: # Don't allow things to go out of domain fixed.pop() + else: + raise RelativeSourceError() return '/'.join(fixed) def resolvesource(ui, svnroot, source):