[Sugar-devel] [PATCH sugar] Journal detail view: don't choke on invalid 'keep' property

Sascha Silbe silbe at activitycentral.com
Wed Nov 2 18:28:28 EDT 2011


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>
---

Tested using the data store attached to the ticket referenced above.

 src/jarabe/journal/expandedentry.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/jarabe/journal/expandedentry.py b/src/jarabe/journal/expandedentry.py
index 495c7e9..caf6003 100644
--- a/src/jarabe/journal/expandedentry.py
+++ b/src/jarabe/journal/expandedentry.py
@@ -147,7 +147,7 @@ class ExpandedEntry(hippo.CanvasBox):
         self._metadata = metadata
         self._object_id = object_id

-        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()
--
1.7.6.3



More information about the Sugar-devel mailing list