mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
fix encoding error on *too* random bytes
This should fix things like: def __init__(self, val): self.val = val.decode("string_escape") ValueError: Trailing \ in string pathod/language/base.py:108: ValueError test/pathod/test_language_websocket.py:83: in fr return netlib.websockets.Frame.from_bytes(tutils.render(wf, settings)) test/pathod/tutils.py:123: in render r = r.resolve(settings) pathod/language/websockets.py:179: in resolve Key(base.TokValueLiteral(os.urandom(4)))
This commit is contained in:
parent
2887480bcb
commit
55a17b2ed3
@ -1,4 +1,6 @@
|
||||
import os
|
||||
import random
|
||||
import string
|
||||
import netlib.websockets
|
||||
import pyparsing as pp
|
||||
from . import base, generators, actions, message
|
||||
@ -175,8 +177,10 @@ class WebsocketFrame(message.Message):
|
||||
Mask(True)
|
||||
)
|
||||
if not self.knone and self.mask and self.mask.value and not self.key:
|
||||
allowed_chars = string.ascii_letters + string.digits
|
||||
k = ''.join([allowed_chars[random.randrange(0, len(allowed_chars))] for i in range(4)])
|
||||
tokens.append(
|
||||
Key(base.TokValueLiteral(os.urandom(4)))
|
||||
Key(base.TokValueLiteral(k))
|
||||
)
|
||||
return self.__class__(
|
||||
[i.resolve(settings, self) for i in tokens]
|
||||
|
Loading…
Reference in New Issue
Block a user