[Sugar-devel] [PATCH sugar v3] Journal detail view: don't choke on invalid 'keep' property (fixes SL#1591)
Sascha Silbe
silbe at activitycentral.com
Mon Jan 23 16:21:48 EST 2012
Properties of data store entries can get corrupted, e.g. due to low level
crashes or running out of battery (see OLPC#11372 [1] for a real-life
example). In addition any activity can - accidentally or on purpose - write
data store entries with arbitrary metadata.
By comparing the 'keep' property as a string we can avoid the ValueError that
might happen when trying to convert the property value to an integer.
[1] https://dev.laptop.org/ticket/11372
Reported-by: Gary Martin <garycmartin at googlemail.com>
Signed-off-by: Sascha Silbe <silbe at activitycentral.com>
---
v1->v2: fix get_keep() as well; mark SL#1591 as fixed
v2->v3: fix cut&pasto. Forgot to amend the commit before sending the patch. Sorry!
src/jarabe/journal/expandedentry.py | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/jarabe/journal/expandedentry.py b/src/jarabe/journal/expandedentry.py
index 4e99dc2..03f8cd1 100644
--- a/src/jarabe/journal/expandedentry.py
+++ b/src/jarabe/journal/expandedentry.py
@@ -144,7 +144,7 @@ def set_metadata(self, metadata):
return
self._metadata = metadata
- self._keep_icon.keep = (int(metadata.get('keep', 0)) == 1)
+ self._keep_icon.keep = (str(metadata.get('keep', 0)) == '1')
self._icon = self._create_icon()
self._icon_box.clear()
@@ -419,7 +419,7 @@ def _update_entry(self, needs_update=False):
self._update_title_sid = None
def get_keep(self):
- return int(self._metadata.get('keep', 0)) == 1
+ return (str(self._metadata.get('keep', 0)) == '1')
def _keep_icon_activated_cb(self, keep_icon):
if self.get_keep():
--
1.7.6
More information about the Sugar-devel
mailing list