details: https://code.tryton.org/tryton/commit/e592ed66d339
branch: default
user: Cédric Krier <[email protected]>
date: Sat Nov 21 18:13:00 2026 +0100
description:
Limit the decompressed size of request
Closes #15257
diffstat:
trytond/CHANGELOG | 1 +
trytond/trytond/protocols/wrappers.py | 13 ++++++++-----
2 files changed, 9 insertions(+), 5 deletions(-)
diffs (45 lines):
diff -r 489f0c6a6959 -r e592ed66d339 trytond/CHANGELOG
--- a/trytond/CHANGELOG Sat Nov 21 15:24:53 2026 +0100
+++ b/trytond/CHANGELOG Sat Nov 21 18:13:00 2026 +0100
@@ -1,3 +1,4 @@
+* Limit the decompressed size of request (issue15257)
* Define the forbidden fields that cannot be set as preferences (issue15256)
* Add scheduled task to synchronize local translations
* Support creating and writing translated fields in multiple languages at once
diff -r 489f0c6a6959 -r e592ed66d339 trytond/trytond/protocols/wrappers.py
--- a/trytond/trytond/protocols/wrappers.py Sat Nov 21 15:24:53 2026 +0100
+++ b/trytond/trytond/protocols/wrappers.py Sat Nov 21 18:13:00 2026 +0100
@@ -3,6 +3,7 @@
import base64
import collections
import gzip
+import io
import logging
import time
import zlib
@@ -15,7 +16,7 @@
from werkzeug import exceptions
from werkzeug.datastructures import Authorization
-from werkzeug.exceptions import BadRequest, abort
+from werkzeug.exceptions import BadRequest, RequestEntityTooLarge, abort
from werkzeug.utils import redirect, send_file
from werkzeug.wrappers import Request as BaseRequest
from werkzeug.wrappers import Response as BaseResponse
@@ -116,10 +117,12 @@
@property
def decoded_data(self):
if self.content_encoding == 'gzip':
- if self.user_id:
- return gzip.decompress(self.data)
- else:
- abort(HTTPStatus.UNSUPPORTED_MEDIA_TYPE)
+ with gzip.GzipFile(
+ fileobj=io.BytesIO(self.data), mode='rb') as stream:
+ data = stream.read(self.max_content_length + 1)
+ if len(data) > self.max_content_length:
+ raise RequestEntityTooLarge()
+ return data
else:
return self.data