From 983eeeeccf8e8e5bd93b03e7db59248a726ab49e Mon Sep 17 00:00:00 2001 From: Yuval Adam <_@yuv.al> Date: Sun, 11 Mar 2018 20:27:41 +0200 Subject: Add basic support for color parsing, placeholder only for now (no spec) --- viewstate/parse.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/viewstate/parse.py b/viewstate/parse.py index b77ba34..7055ab6 100644 --- a/viewstate/parse.py +++ b/viewstate/parse.py @@ -39,6 +39,12 @@ def parse_enum(b): final = 'Enum: {}, val: {}'.format(enum, val) return final, remain +def parse_color(b): + # No specification for color parsing, we're assuming it's just two bytes + # One example we have is that `\n\x91\x01` is parsed as `Color: Color [Salmon]` + # Originally reported in https://github.com/yuvadm/viewstate/issues/2 + return 'Color: unknown', b[2:] + def parse_pair(b): first, remain = parse(b) second, remain = parse(remain) @@ -125,6 +131,8 @@ def parse(b): return parse_string(b[1:]) elif b[0] == 0x10: return parse_triplet(b[1:]) + elif b[0] == 0x0a: + return parse_color(b[1:]) elif b[0] == 0x0b: return parse_enum(b[1:]) elif b[0] == 0x0f: @@ -134,6 +142,7 @@ def parse(b): elif b[0] == 0x15: return parse_str_array(b[1:]) elif b[0] == 0x16: + print('parse array', b[:20]) return parse_array(b[1:]) elif b[0] == 0x18: return parse_dict(b[1:]) -- cgit v1.3.1