summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-09-29 01:49:05 +0000
committerZac Medico <zmedico@gentoo.org>2007-09-29 01:49:05 +0000
commitedc2a8d30a984b50a262399e631929a4332f0a14 (patch)
tree2d4e788b91a342aa5f91835c58f2440bd02f5f41
parent39c8ff5ddf72d0e9be0b0ed8338065e82f8e770e (diff)
downloadportage-edc2a8d30a984b50a262399e631929a4332f0a14.tar.gz
portage-edc2a8d30a984b50a262399e631929a4332f0a14.tar.bz2
portage-edc2a8d30a984b50a262399e631929a4332f0a14.zip
Bug #194095 - Validate dispatch-conf input in order to
prevent spurious input characters from being interpreted as user input (which can be quite confusing and gives an "out of control" feeling). svn path=/main/trunk/; revision=7877
-rwxr-xr-xbin/dispatch-conf15
1 files changed, 13 insertions, 2 deletions
diff --git a/bin/dispatch-conf b/bin/dispatch-conf
index c1dd7a3d1..e000880f0 100755
--- a/bin/dispatch-conf
+++ b/bin/dispatch-conf
@@ -203,6 +203,8 @@ class dispatch:
# Interactively process remaining
#
+ valid_input = "qhtnmlezu"
+
for conf in confs:
count = count + 1
@@ -223,7 +225,16 @@ class dispatch:
print '>> (%i of %i) -- %s' % (count, len(confs), conf ['current'])
print '>> q quit, h help, n next, e edit-new, z zap-new, u use-new\n m merge, t toggle-merge, l look-merge: ',
- c = getch ()
+ # In some cases getch() will return some spurious characters
+ # that do not represent valid input. If we don't validate the
+ # input then the spurious characters can cause us to jump
+ # back into the above "diff" command immediatly after the user
+ # has exited it (which can be quite confusing and gives an
+ # "out of control" feeling).
+ while True:
+ c = getch()
+ if c in valid_input:
+ break
if c == 'q':
sys.exit (0)
@@ -274,7 +285,7 @@ class dispatch:
os.unlink(mrgconf)
break
else:
- continue
+ raise AssertionError("Invalid Input: %s" % c)
if auto_zapped:
print