changeset 18910:b52404a914a9

scheme: don't crash on invalid URLs
author Mads Kiilerich <madski@unity3d.com>
date Thu, 11 Apr 2013 14:41:22 +0200
parents 3a72c89a83ec
children 451eb1c27c1b
files hgext/schemes.py tests/test-schemes.t
diffstat 2 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/schemes.py	Fri Feb 08 21:08:34 2013 +0000
+++ b/hgext/schemes.py	Thu Apr 11 14:41:22 2013 +0200
@@ -62,7 +62,10 @@
 
     def instance(self, ui, url, create):
         # Should this use the util.url class, or is manual parsing better?
-        url = url.split('://', 1)[1]
+        try:
+            url = url.split('://', 1)[1]
+        except IndexError:
+            raise util.Abort(_("no '://' in scheme url '%s'") % url)
         parts = url.split('/', self.parts)
         if len(parts) > self.parts:
             tail = parts[-1]
--- a/tests/test-schemes.t	Fri Feb 08 21:08:34 2013 +0000
+++ b/tests/test-schemes.t	Thu Apr 11 14:41:22 2013 +0200
@@ -14,6 +14,15 @@
   $ echo a > a
   $ hg ci -Am initial
   adding a
+
+invalid scheme
+
+  $ hg log -R z:z
+  abort: no '://' in scheme url 'z:z'
+  [255]
+
+http scheme
+
   $ hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
   $ cat hg.pid >> $DAEMON_PIDS
   $ hg incoming l://