Skip to content

Commit

Permalink
- prevent the creation of object IDs that look like views (#598)
Browse files Browse the repository at this point in the history
  • Loading branch information
dataflake committed May 9, 2019
1 parent fdf9708 commit fe0bc43
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ https://github.com/zopefoundation/Zope/blob/4.0a6/CHANGES.rst
Fixes
+++++

- Make sure new object IDs don't clash with the views lookup mechanism
(`#591 <https://github.com/zopefoundation/Zope/issues/591>`_)

- Be more careful when guessing at encoding for document template types

- Ensure a redirect path does not get URL-encoded twice
Expand Down
4 changes: 4 additions & 0 deletions src/OFS/ObjectManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ def checkValidId(self, id, allow_dup=0):
raise BadRequest(
'The id "%s" is invalid because it '
'ends with two underscores.' % id)
if id.startswith('@@') or id.startswith('++'):
raise BadRequest(
'The id "%s" is invalid because it starts with characters '
'reserved for Zope views lookup.' % id)
if not allow_dup:
obj = getattr(self, id, None)
if obj is not None:
Expand Down
2 changes: 2 additions & 0 deletions src/OFS/tests/testObjectManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,8 @@ def test_setObject_checkId_bad(self):
self.assertRaises(BadRequest, om._setObject, 'foo>bar', si)
self.assertRaises(BadRequest, om._setObject, 'foo<bar', si)
self.assertRaises(BadRequest, om._setObject, 'foo/bar', si)
self.assertRaises(BadRequest, om._setObject, '@@ohno', si)
self.assertRaises(BadRequest, om._setObject, '++ohno', si)

def test_getsetitem(self):
om = self._makeOne()
Expand Down

0 comments on commit fe0bc43

Please sign in to comment.