diff options
| author | Yuval Adam <yuval@y3xz.com> | 2016-03-24 22:21:23 +0200 |
|---|---|---|
| committer | Yuval Adam <yuval@y3xz.com> | 2016-03-24 22:21:23 +0200 |
| commit | f8ec6c5a397d884a039811aac8d64d2759fe0b6f (patch) | |
| tree | 1fbf05144b87b22fd43c488dabc405342cbb4656 | |
| parent | 0903f9b06475cdd95212acacd50748acf7106759 (diff) | |
Implement True value parsing
| -rw-r--r-- | test.py | 8 | ||||
| -rw-r--r-- | viewstate.py | 16 |
2 files changed, 12 insertions, 12 deletions
@@ -19,10 +19,10 @@ class TestViewState(unittest.TestCase): vs.raw = b'\x01\x02' vs.decode() - # def test_parse(self): - # vs = ViewState() - # vs.raw = b'\xff\x01\x67' - # self.assertTrue(vs.decode()) + def test_parse_const_value(self): + vs = ViewState() + vs.raw = b'\xff\x01\x67' + self.assertEquals(vs.decode(), True) if __name__ == '__main__': unittest.main() diff --git a/viewstate.py b/viewstate.py index 01417a4..bf14005 100644 --- a/viewstate.py +++ b/viewstate.py @@ -2,17 +2,17 @@ from base64 import b64decode, b64encode CONSTS = { - '\x64': {}, - '\x65': '', - '\x66': 0, - '\x67': True, - '\x68': False + 100: {}, + 101: '', + 102: 0, + 103: True, + 104: False } def parse(b): - print([hex(x) for x in b]) - if len(b) == 1 and b in CONSTS: - return CONSTS[b] + assert type(b) == bytes().__class__ + if len(b) == 1 and b[0] in CONSTS: + return CONSTS[b[0]] return None |
