aboutsummaryrefslogtreecommitdiffstats
path: root/netlib/websockets.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2015-04-21 23:49:27 +1200
committerAldo Cortesi <aldo@nullcube.com>2015-04-21 23:49:27 +1200
commit4fb49c8e55cc3c64ac0d5cf8fb913518f1973162 (patch)
tree51656bd7600ffe2e34f42162fefece05498fd480 /netlib/websockets.py
parent176e29fc094119b036ba76d6e5cc1f2d7fb838e0 (diff)
downloadmitmproxy-4fb49c8e55cc3c64ac0d5cf8fb913518f1973162.tar.gz
mitmproxy-4fb49c8e55cc3c64ac0d5cf8fb913518f1973162.tar.bz2
mitmproxy-4fb49c8e55cc3c64ac0d5cf8fb913518f1973162.zip
websockets: (very) slightly nicer is_valid constraints
Diffstat (limited to 'netlib/websockets.py')
-rw-r--r--netlib/websockets.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/netlib/websockets.py b/netlib/websockets.py
index 1e9c96cc..d5c5c2fe 100644
--- a/netlib/websockets.py
+++ b/netlib/websockets.py
@@ -129,14 +129,12 @@ class Frame(object):
1 <= self.opcode <= 4,
0 <= self.mask_bit <= 1,
1 <= self.payload_length_code <= 127,
- self.actual_payload_length == len(self.payload)
+ self.actual_payload_length == len(self.payload),
+ 1 <= len(self.masking_key) <= 4 if self.mask_bit else True,
+ self.masking_key is not None if self.mask_bit else True
]
if not all(constraints):
return False
- elif self.mask_bit == 1 and not 1 <= len(self.masking_key) <= 4:
- return False
- elif self.mask_bit == 0 and self.masking_key is not None:
- return False
elif self.payload and self.masking_key:
decoded = apply_mask(self.payload, self.masking_key)
if decoded != self.decoded_payload: