Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a write on read situation #2

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Changelog
2.0.5 (unreleased)
------------------

- Nothing changed yet.

- CSRF fix: safe write on read.
[gforcada]

2.0.4 (2014-01-27)
------------------
Expand Down
8 changes: 7 additions & 1 deletion plone/contentrules/engine/assignments.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
from plone.contentrules.engine.interfaces import IRuleAssignment
from plone.contentrules.engine.interfaces import IRuleAssignmentManager

from plone.protect.auto import safeWrite

from BTrees.OOBTree import OOBTree


Expand Down Expand Up @@ -85,6 +87,10 @@ def ruleAssignmentManagerAdapterFactory(context):
annotations = IAnnotations(context)
manager = annotations.get(KEY, None)
if manager is None:
manager = annotations[KEY] = RuleAssignmentManager()
annotations[KEY] = RuleAssignmentManager()
manager = annotations[KEY]
# protect both context and its annotations from a write on read error
safeWrite(context)
safeWrite(context.__annotations__)

return manager