update
Some checks are pending
Setup Native Action / native (3.12.7) (push) Waiting to run
Setup Native Action / docker (3.12.7) (push) Waiting to run

This commit is contained in:
KaySar12 2025-06-20 11:47:49 +07:00
parent 59a148076b
commit 8923642a72

View File

@ -136,6 +136,7 @@ import functools
import glob import glob
import hashlib import hashlib
import hmac import hmac
import importlib.metadata
import inspect import inspect
import json import json
import logging import logging
@ -145,7 +146,6 @@ import re
import threading import threading
import time import time
import traceback import traceback
import warnings
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from datetime import datetime, timedelta from datetime import datetime, timedelta
from hashlib import sha512 from hashlib import sha512
@ -278,7 +278,7 @@ ROUTING_KEYS = {
'alias', 'host', 'methods', 'alias', 'host', 'methods',
} }
if parse_version(werkzeug.__version__) >= parse_version('2.0.2'): if parse_version(importlib.metadata.version('werkzeug')) >= parse_version('2.0.2'):
# Werkzeug 2.0.2 adds the websocket option. If a websocket request # Werkzeug 2.0.2 adds the websocket option. If a websocket request
# (ws/wss) is trying to access an HTTP route, a WebsocketMismatch # (ws/wss) is trying to access an HTTP route, a WebsocketMismatch
# exception is raised. On the other hand, Werkzeug 0.16 does not # exception is raised. On the other hand, Werkzeug 0.16 does not
@ -711,7 +711,7 @@ def route(route=None, **routing):
# Sanitize the routing # Sanitize the routing
assert routing.get('type', 'http') in _dispatchers.keys() assert routing.get('type', 'http') in _dispatchers.keys()
if route: if route:
routing['routes'] = route if isinstance(route, list) else [route] routing['routes'] = [route] if isinstance(route, str) else route
wrong = routing.pop('method', None) wrong = routing.pop('method', None)
if wrong is not None: if wrong is not None:
_logger.warning("%s defined with invalid routing parameter 'method', assuming 'methods'", fname) _logger.warning("%s defined with invalid routing parameter 'method', assuming 'methods'", fname)
@ -1278,6 +1278,7 @@ class HTTPRequest:
httprequest.user_agent_class = UserAgent # use vendored userAgent since it will be removed in 2.1 httprequest.user_agent_class = UserAgent # use vendored userAgent since it will be removed in 2.1
httprequest.parameter_storage_class = werkzeug.datastructures.ImmutableOrderedMultiDict httprequest.parameter_storage_class = werkzeug.datastructures.ImmutableOrderedMultiDict
httprequest.max_content_length = DEFAULT_MAX_CONTENT_LENGTH httprequest.max_content_length = DEFAULT_MAX_CONTENT_LENGTH
httprequest.max_form_memory_size = 10 * 1024 * 1024 # 10 MB
self.__wrapped = httprequest self.__wrapped = httprequest
self.__environ = self.__wrapped.environ self.__environ = self.__wrapped.environ
@ -1739,7 +1740,7 @@ class Request:
if isinstance(location, URL): if isinstance(location, URL):
location = location.to_url() location = location.to_url()
if local: if local:
location = '/' + url_parse(location).replace(scheme='', netloc='').to_url().lstrip('/') location = '/' + url_parse(location).replace(scheme='', netloc='').to_url().lstrip('/\\')
if self.db: if self.db:
return self.env['ir.http']._redirect(location, code) return self.env['ir.http']._redirect(location, code)
return werkzeug.utils.redirect(location, code, Response=Response) return werkzeug.utils.redirect(location, code, Response=Response)
@ -1831,8 +1832,12 @@ class Request:
try: try:
directory = root.statics[module] directory = root.statics[module]
filepath = werkzeug.security.safe_join(directory, path) filepath = werkzeug.security.safe_join(directory, path)
debug = (
'assets' in self.session.debug and
' wkhtmltopdf ' not in self.httprequest.user_agent.string
)
res = Stream.from_path(filepath, public=True).get_response( res = Stream.from_path(filepath, public=True).get_response(
max_age=0 if 'assets' in self.session.debug else STATIC_CACHE, max_age=0 if debug else STATIC_CACHE,
content_security_policy=None, content_security_policy=None,
) )
root.set_csp(res) root.set_csp(res)
@ -1963,7 +1968,8 @@ class Request:
raise # bubble up to odoo.http.Application.__call__ raise # bubble up to odoo.http.Application.__call__
if 'werkzeug' in config['dev_mode'] and self.dispatcher.routing_type != 'json': if 'werkzeug' in config['dev_mode'] and self.dispatcher.routing_type != 'json':
raise # bubble up to werkzeug.debug.DebuggedApplication raise # bubble up to werkzeug.debug.DebuggedApplication
exc.error_response = self.registry['ir.http']._handle_error(exc) if not hasattr(exc, 'error_response'):
exc.error_response = self.registry['ir.http']._handle_error(exc)
raise raise
@ -2204,7 +2210,7 @@ class JsonRPCDispatcher(Dispatcher):
response = {'jsonrpc': '2.0', 'id': self.request_id} response = {'jsonrpc': '2.0', 'id': self.request_id}
if error is not None: if error is not None:
response['error'] = error response['error'] = error
if result is not None: else:
response['result'] = result response['result'] = result
return self.request.make_json_response(response) return self.request.make_json_response(response)
@ -2271,7 +2277,7 @@ class Application:
for url, endpoint in _generate_routing_rules([''] + odoo.conf.server_wide_modules, nodb_only=True): for url, endpoint in _generate_routing_rules([''] + odoo.conf.server_wide_modules, nodb_only=True):
routing = submap(endpoint.routing, ROUTING_KEYS) routing = submap(endpoint.routing, ROUTING_KEYS)
if routing['methods'] is not None and 'OPTIONS' not in routing['methods']: if routing['methods'] is not None and 'OPTIONS' not in routing['methods']:
routing['methods'] = routing['methods'] + ['OPTIONS'] routing['methods'] = [*routing['methods'], 'OPTIONS']
rule = werkzeug.routing.Rule(url, endpoint=endpoint, **routing) rule = werkzeug.routing.Rule(url, endpoint=endpoint, **routing)
rule.merge_slashes = False rule.merge_slashes = False
nodb_routing_map.add(rule) nodb_routing_map.add(rule)
@ -2360,8 +2366,7 @@ class Application:
if self.get_static_file(httprequest.path): if self.get_static_file(httprequest.path):
response = request._serve_static() response = request._serve_static()
elif request.db or httprequest.path.startswith('/preview-url/'): elif request.db:
request.db = httprequest.args.get('db', request.db).split('?')[0] if httprequest.args.get('db') else request.db
try: try:
with request._get_profiler_context_manager(): with request._get_profiler_context_manager():
response = request._serve_db() response = request._serve_db()