##// END OF EJS Templates
url: abort on file:// URLs with non-localhost hosts
Brodie Rao -
r13817:7f18bab2 default
parent child Browse files
Show More
@@ -140,6 +140,11 b' class url(object):'
140 self.host, self.port = self.host.rsplit(':', 1)
140 self.host, self.port = self.host.rsplit(':', 1)
141 if not self.host:
141 if not self.host:
142 self.host = None
142 self.host = None
143
144 if (self.host and self.scheme == 'file' and
145 self.host not in ('localhost', '127.0.0.1', '[::1]')):
146 raise util.Abort(_('file:// URLs can only refer to localhost'))
147
143 self.path = path
148 self.path = path
144
149
145 for a in ('user', 'passwd', 'host', 'port',
150 for a in ('user', 'passwd', 'host', 'port',
@@ -78,4 +78,8 b' regular shell commands.'
78
78
79 $ URL=`python -c "import os; print 'file://foobar' + ('/' + os.getcwd().replace(os.sep, '/')).replace('//', '/') + '/../test'"`
79 $ URL=`python -c "import os; print 'file://foobar' + ('/' + os.getcwd().replace(os.sep, '/')).replace('//', '/') + '/../test'"`
80 $ hg pull -q "$URL"
80 $ hg pull -q "$URL"
81 abort: file:// URLs can only refer to localhost
82 [255]
81
83
84 $ URL=`python -c "import os; print 'file://localhost' + ('/' + os.getcwd().replace(os.sep, '/')).replace('//', '/') + '/../test'"`
85 $ hg pull -q "$URL"
@@ -158,6 +158,13 b' def test_url():'
158 >>> url('/x///z/y/')
158 >>> url('/x///z/y/')
159 <url path: '/x///z/y/'>
159 <url path: '/x///z/y/'>
160
160
161 Non-localhost file URL:
162
163 >>> u = url('file://mercurial.selenic.com/foo')
164 Traceback (most recent call last):
165 File "<stdin>", line 1, in ?
166 Abort: file:// URLs can only refer to localhost
167
161 Empty URL:
168 Empty URL:
162
169
163 >>> u = url('')
170 >>> u = url('')
General Comments 0
You need to be logged in to leave comments. Login now