diff --git a/vk_api/vk_api.py b/vk_api/vk_api.py index e4344e4..8d4333b 100644 --- a/vk_api/vk_api.py +++ b/vk_api/vk_api.py @@ -665,7 +665,15 @@ def method(self, method, values=None, captcha_sid=None, captcha_key=None, self.last_request = time.time() if response.ok: - response = response.json() + try: + response = response.json() + except json.decoder.JSONDecodeError: + # This allows control characters + response = response.json(strict=False) + # Alternative: replace control characters with + # empty string + # sanitized = re.sub(r'[\x00-\x1f\x7f-\x9f]', '', response.content) + # response = json.loads(sanitized) else: error = ApiHttpError(self, method, values, raw, response) response = self.http_handler(error)