[Sugar-devel] [PATCH sugar] Copy to external device: do not fail on custom binary metadata OLPC #10807

Simon Schampijer simon at schampijer.de
Mon Apr 4 13:36:31 EDT 2011


Catch 'UnicodeDecodeError' and do not write the metadata
if that error occurs but still write the file itself. This might be
enough and the guidelines should maybe ask the activity authors
to not use binary blobs for metadata, or base64 them before storing
them in the metadata. More reasoning and background information
in the ticket itself.
---
 src/jarabe/journal/model.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/jarabe/journal/model.py b/src/jarabe/journal/model.py
index 9cea65e..c768e2a 100644
--- a/src/jarabe/journal/model.py
+++ b/src/jarabe/journal/model.py
@@ -717,7 +717,7 @@ def _write_entry_on_external_device(metadata, file_path):
 
     try:
         metadata_json = simplejson.dumps(metadata_copy)
-    except EnvironmentError:
+    except (UnicodeDecodeError, EnvironmentError):
         logging.error('Could not convert metadata to json.')
     else:
         (fh, fn) = tempfile.mkstemp(dir=metadata['mountpoint'])
-- 
1.7.4



More information about the Sugar-devel mailing list