Commit b13cf2ce authored by Jens Vagelpohl's avatar Jens Vagelpohl

- LP #143403: Prevent accidental acquisition of objectValues during

  recursive ownership changes when the changed object has no
  objectValues method.
parent d93a07c4
...@@ -181,6 +181,10 @@ Features Added ...@@ -181,6 +181,10 @@ Features Added
Bugs Fixed Bugs Fixed
++++++++++ ++++++++++
- LP #143403: Prevent accidental acquisition of objectValues during
recursive ownership changes when the changed object has no
objectValues method.
- LP #142535: Fix faulty docstring for manage_changeProperties which - LP #142535: Fix faulty docstring for manage_changeProperties which
incorrectly suggested that passing a simple dictionary as REQUEST incorrectly suggested that passing a simple dictionary as REQUEST
argument was supported. argument was supported.
......
...@@ -166,7 +166,8 @@ class Owned(Base): ...@@ -166,7 +166,8 @@ class Owned(Base):
return return
if recursive: if recursive:
for child in self.objectValues(): children = getattr( aq_base(self), 'objectValues', lambda :() )()
for child in children:
child.changeOwnership(user, 1) child.changeOwnership(user, 1)
if old is not UnownableOwner: if old is not UnownableOwner:
......
...@@ -273,6 +273,24 @@ class OwnershipChangeTests(unittest.TestCase): ...@@ -273,6 +273,24 @@ class OwnershipChangeTests(unittest.TestCase):
, (['acl_users'], 'user2') , (['acl_users'], 'user2')
) )
def test_changeOwnership_recursive_objectValues_acquisition(self):
# See https://bugs.launchpad.net/bugs/143403
from AccessControl.Owned import Owned
class FauxContent(Implicit, Owned):
pass
previous_parent_owner = self.root.parent._owner
previous_child_owner = self.root.parent.child._owner
previous_grandchild_owner = self.root.parent.child.grandchild._owner
newuser = self.uf.getUser('user2').__of__(self.uf)
self.root.parent.bad = FauxContent()
self.root.parent.bad.changeOwnership(newuser, recursive=True)
self.assertEquals(self.root.parent._owner, previous_parent_owner)
self.assertEquals(self.root.parent.child._owner, previous_child_owner)
self.assertEquals( self.root.parent.child.grandchild._owner
, previous_grandchild_owner
)
def test_suite(): def test_suite():
return unittest.TestSuite(( return unittest.TestSuite((
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment