Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/rpms/sugar-toolkit/sugar-toolkit-4-4-XoColor-don-t-choke-if-passed-the-wrong-type-SL-1408.patch
blob: 0ad36b11cbe5660e8427cff93752c9e038d14fdc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
From patchwork Sat Jan 15 17:07:19 2011
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: [sugar-toolkit,
	4/4] XoColor: don't choke if passed the wrong type (SL#1408)
Date: Sat, 15 Jan 2011 22:07:19 -0000
From: Aleksey Lim <alsroot@member.fsf.org>
X-Patchwork-Id: 576
Message-Id: <1295111239-22177-5-git-send-email-alsroot@member.fsf.org>
To: dextrose@lists.sugarlabs.org

From: Sascha Silbe <sascha-pgp@silbe.org>

Color data is stored in the Journal as a JSON dump, so we can get back
arbitrary types. XoColor already checks the color string for validity and
handles invalid strings gracefully, so it makes sense to enhance this to
invalid types as well.

Acked-by: Simon Schampijer <simon@schampijer.de>

---
src/sugar/graphics/xocolor.py |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/src/sugar/graphics/xocolor.py b/src/sugar/graphics/xocolor.py
index fd329cb..036d695 100644
--- a/src/sugar/graphics/xocolor.py
+++ b/src/sugar/graphics/xocolor.py
@@ -209,6 +209,10 @@ colors = [
 
 
 def _parse_string(color_string):
+    if not isinstance(color_string, (str, unicode)):
+        logging.error('Invalid color string: %r', color_string)
+        return None
+
     if color_string == 'white':
         return ['#ffffff', '#414141']
     elif color_string == 'insensitive':