[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[virt-tools-list] [python-virtinst PATCH] Don't support comments in parsed parameters



Until now, when virtinst was parsing parameters, '#' were used as
starts of a comment, '\' as escape strings etc. due to the use of
shlex.  The use of '\' is predictable (e.g. filename with a ',' in
it), but the '#' is usually escaped in shell only.  Also, even when
not escaped, shlex is not fully compatible with some syntax rules for
parsing '#'.

For example '#' in 'echo asdf#fdsa' will not be used as a comment in
bash (there is no whitespace in front of the '#'), but in our '--disk
name#something.img' (parsed using shlex), it will be used as a comment
even though it is not expected from the user.

Removing '#' (the only character) from shlex.commenters disables all
similar comments, which is desired as users won't be trying to use
comments to comment out parts of parameters.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=916878
---
I'm pushing this as a 'trivial'.

 virtinst/cli.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/virtinst/cli.py b/virtinst/cli.py
index 992b531..79d59d9 100644
--- a/virtinst/cli.py
+++ b/virtinst/cli.py
@@ -1,7 +1,7 @@
 #
 # Utility functions for the command line drivers
 #
-# Copyright 2006-2007  Red Hat, Inc.
+# Copyright 2006-2007, 2013  Red Hat, Inc.
 # Jeremy Katz <katzj redhat com>
 #
 # This program is free software; you can redistribute it and/or modify
@@ -1186,6 +1186,7 @@ def parse_optstr_tuples(optstr, compress_first=False):
         return [(optstr, None)]

     argsplitter = shlex.shlex(optstr, posix=True)
+    argsplitter.commenters = ""
     argsplitter.whitespace = ","
     argsplitter.whitespace_split = True

--
1.8.1.5


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]