# HG changeset patch # User RhodeCode Admin # Date 2024-08-28 11:29:10 # Node ID 95e59c412bdfc7cfa3db7d5905548cbf1927e94c # Parent 9517593bad3c7300835b1cb74bbc4b5f90107fcc fix(mailing): patch repozesendmail to properly use CRLF for newlines. Fixes RFC5322 Issues with mailing diff --git a/rhodecode/api/__init__.py b/rhodecode/api/__init__.py --- a/rhodecode/api/__init__.py +++ b/rhodecode/api/__init__.py @@ -40,6 +40,7 @@ from rhodecode.lib import ext_json from rhodecode.lib.utils2 import safe_str from rhodecode.lib.plugins.utils import get_plugin_settings from rhodecode.model.db import User, UserApiKeys +from rhodecode.config.patches import inspect_getargspec log = logging.getLogger(__name__) @@ -186,7 +187,6 @@ def request_view(request): exposed method """ # cython compatible inspect - from rhodecode.config.patches import inspect_getargspec inspect = inspect_getargspec() # check if we can find this session using api_key, get_by_auth_token diff --git a/rhodecode/api/views/server_api.py b/rhodecode/api/views/server_api.py --- a/rhodecode/api/views/server_api.py +++ b/rhodecode/api/views/server_api.py @@ -328,8 +328,8 @@ def get_method(request, apiuser, pattern ] error : null """ - from rhodecode.config.patches import inspect_getargspec - inspect = inspect_getargspec() + from rhodecode.config import patches + inspect = patches.inspect_getargspec() if not has_superadmin_permission(apiuser): raise JSONRPCForbidden() diff --git a/rhodecode/config/middleware.py b/rhodecode/config/middleware.py --- a/rhodecode/config/middleware.py +++ b/rhodecode/config/middleware.py @@ -35,7 +35,7 @@ from pyramid.renderers import render_to_ from rhodecode.model import meta from rhodecode.config import patches -from rhodecode.config.environment import load_pyramid_environment +from rhodecode.config.environment import load_pyramid_environment, propagate_rhodecode_config import rhodecode.events from rhodecode.config.config_maker import sanitize_settings_and_apply_defaults @@ -99,6 +99,7 @@ def make_pyramid_app(global_config, **se # Apply compatibility patches patches.inspect_getargspec() + patches.repoze_sendmail_lf_fix() load_pyramid_environment(global_config, settings) diff --git a/rhodecode/config/patches.py b/rhodecode/config/patches.py --- a/rhodecode/config/patches.py +++ b/rhodecode/config/patches.py @@ -158,3 +158,10 @@ def inspect_getargspec(): inspect.getargspec = inspect.getfullargspec return inspect + + +def repoze_sendmail_lf_fix(): + from repoze.sendmail import encoding + from email.policy import SMTP + + encoding.encode_message = lambda message, *args, **kwargs: message.as_bytes(policy=SMTP) diff --git a/rhodecode/lib/celerylib/loader.py b/rhodecode/lib/celerylib/loader.py --- a/rhodecode/lib/celerylib/loader.py +++ b/rhodecode/lib/celerylib/loader.py @@ -27,10 +27,11 @@ Celery loader, run with:: --scheduler rhodecode.lib.celerylib.scheduler.RcScheduler \ --loglevel DEBUG --ini=.dev/dev.ini """ -from rhodecode.config.patches import inspect_getargspec, inspect_formatargspec -inspect_getargspec() -inspect_formatargspec() +from rhodecode.config import patches +patches.inspect_getargspec() +patches.inspect_formatargspec() # python3.11 inspect patches for backward compat on `paste` code +patches.repoze_sendmail_lf_fix() import sys import logging