--- a/src/modules/actions/generic.py Wed Jun 06 16:52:57 2012 -0700
+++ b/src/modules/actions/generic.py Wed Jun 06 18:11:11 2012 -0700
@@ -257,7 +257,8 @@
try:
h = self.hash
if h:
- if "=" not in h:
+ if "=" not in h and " " not in h and \
+ '"' not in h:
out += " " + h
else:
sattrs.append("hash")
@@ -892,7 +893,7 @@
try:
value = self.attrs[name]
except KeyError:
- return []
+ return []
if type(value) is not list:
return [value]
return value
--- a/src/tests/api/t_action.py Wed Jun 06 16:52:57 2012 -0700
+++ b/src/tests/api/t_action.py Wed Jun 06 18:11:11 2012 -0700
@@ -289,9 +289,21 @@
self.assert_(not a.different(a2))
# ... unless of course the hash can't be represented that way.
- a = action.fromstr("file hash=abc=123 path=usr/bin/foo mode=0755 owner=root group=bin")
- self.assert_("hash=abc=123" in str(a))
- self.assert_(not str(a).startswith("file abc=123"))
+ d = {
+ "hash=abc=123": "abc=123",
+ "hash=\"one with spaces\"": "one with spaces",
+ "hash='one with \" character'": 'one with " character',
+ "hash=\"'= !@$%^\)(*\"": "'= !@$%^\)(*",
+ """hash="\\"'= \\ " """:""""'= \\ """,
+ '\\' : '\\'
+ }
+
+ astr = "file %s path=usr/bin/foo mode=0755 owner=root group=bin"
+ for k, v in d.iteritems():
+ a = action.fromstr(astr % k)
+ self.assert_(action.fromstr(str(a)) == a)
+ self.assert_(a.hash == v)
+ self.assert_(k in str(a))
def test_action_sig_str(self):
sig_act = action.fromstr(
@@ -478,9 +490,9 @@
assert_invalid_attrs(nact)
# Verify invalid values are not allowed for mode attribute on
- # file and dir actions.
+ # file and dir actions.
for act in (fact, dact):
- for bad_mode in ("", 'mode=""', "mode=???",
+ for bad_mode in ("", 'mode=""', "mode=???",
"mode=44755", "mode=44", "mode=999", "mode=0898"):
nact = act.replace("mode=XXX", bad_mode)
assert_invalid_attrs(nact)