diff --git a/paas2/VERSION b/paas2/VERSION index a1a4224dd..965a689ec 100644 --- a/paas2/VERSION +++ b/paas2/VERSION @@ -1 +1 @@ -2.13.3 +2.13.4 diff --git a/paas2/esb/components/generic/templates/cmsi/send_mail.py b/paas2/esb/components/generic/templates/cmsi/send_mail.py index 6aa972634..a4da8ca64 100644 --- a/paas2/esb/components/generic/templates/cmsi/send_mail.py +++ b/paas2/esb/components/generic/templates/cmsi/send_mail.py @@ -14,6 +14,7 @@ import base64 from django import forms +from django.utils.encoding import force_text from components.component import Component, SetupConfMixin from common.forms import BaseComponentForm, ListField, DefaultBooleanField, TypeCheckField @@ -117,7 +118,7 @@ def clean(self): data["cc__username"] = None if data["is_content_base64"]: try: - data["content"] = base64.b64decode(data["content"]) + data["content"] = force_text(base64.b64decode(data["content"])) except Exception: pass if data["attachments"]: @@ -135,7 +136,7 @@ class AttachmentForm(BaseComponentForm): content_id = forms.CharField(label="content_id", required=False) def clean(self): - self.cleaned_data["content"] = base64.b64decode(self.cleaned_data["content"]) + self.cleaned_data["content"] = force_text(base64.b64decode(self.cleaned_data["content"])) return self.cleaned_data def handle(self): diff --git a/paas2/esb/components/generic/templates/cmsi/send_mp_weixin.py b/paas2/esb/components/generic/templates/cmsi/send_mp_weixin.py index eb8d3a69f..ab6712a7f 100644 --- a/paas2/esb/components/generic/templates/cmsi/send_mp_weixin.py +++ b/paas2/esb/components/generic/templates/cmsi/send_mp_weixin.py @@ -14,6 +14,7 @@ from django import forms from django.utils import timezone +from django.utils.encoding import force_text from components.component import Component, SetupConfMixin from common.forms import BaseComponentForm, ListField, TypeCheckField, DefaultBooleanField @@ -105,7 +106,7 @@ class DataForm(BaseComponentForm): def decode_message(self, message, is_message_base64): if is_message_base64: try: - message = base64.b64decode(message) + message = force_text(base64.b64decode(message)) except Exception: pass return message diff --git a/paas2/esb/components/generic/templates/cmsi/send_sms.py b/paas2/esb/components/generic/templates/cmsi/send_sms.py index c88c9306f..4e1cda9f4 100644 --- a/paas2/esb/components/generic/templates/cmsi/send_sms.py +++ b/paas2/esb/components/generic/templates/cmsi/send_sms.py @@ -14,6 +14,7 @@ import base64 from django import forms +from django.utils.encoding import force_text from components.component import Component, SetupConfMixin from common.forms import BaseComponentForm, ListField, DefaultBooleanField @@ -83,7 +84,7 @@ class Form(BaseComponentForm): def decode_content(self, content, is_content_base64): if is_content_base64: try: - content = base64.b64decode(content) + content = force_text(base64.b64decode(content)) except Exception: pass return content diff --git a/paas2/esb/components/generic/templates/cmsi/send_weixin.py b/paas2/esb/components/generic/templates/cmsi/send_weixin.py index 03de46e0f..170ac20ef 100644 --- a/paas2/esb/components/generic/templates/cmsi/send_weixin.py +++ b/paas2/esb/components/generic/templates/cmsi/send_weixin.py @@ -121,7 +121,7 @@ class DataForm(BaseComponentForm): def decode_message(self, message, is_message_base64): if is_message_base64: try: - message = base64.b64decode(message) + message = force_text(base64.b64decode(message)) except Exception: pass return message diff --git a/paas2/esb/components/generic/templates/cmsi/toolkit/send_mail_with_smtp.py b/paas2/esb/components/generic/templates/cmsi/toolkit/send_mail_with_smtp.py index 57ff59910..5636ec6e2 100644 --- a/paas2/esb/components/generic/templates/cmsi/toolkit/send_mail_with_smtp.py +++ b/paas2/esb/components/generic/templates/cmsi/toolkit/send_mail_with_smtp.py @@ -20,6 +20,8 @@ from email.mime.text import MIMEText from email.utils import COMMASPACE +from django.utils.encoding import force_text + from common.base_utils import smart_str from common.bkerrors import bk_error_codes from common.log import logger @@ -32,7 +34,7 @@ def __init__( self.smtp_host = smtp_host self.smtp_port = smtp_port self.smtp_user = smtp_user - self.smtp_pwd = smart_str(smtp_pwd) + self.smtp_pwd = force_text(smtp_pwd) self.smtp_usessl = smtp_usessl self.smtp_usetls = smtp_usetls self.smtp_timeout = smtp_timeout @@ -91,7 +93,7 @@ def add_attachment_to_msg(self, mail_msg, attachments): # rfc2047: encoded-word = "=?" charset "?" encoding "?" encoded-text "?=" # encoding b for base64 filename = smart_str(f_info.get("filename", "")) - _filename = "=?utf-8?b?" + base64.b64encode(filename) + "?=" + _filename = "=?utf-8?b?" + force_text(base64.b64encode(filename)) + "?=" _content = f_info.get("content", "") _type = f_info.get("type") or _filename.split(".")[-1] or "attachment" _disposition = f_info.get("disposition", "") diff --git a/paas2/esb/components/generic/templates/cmsi/toolkit/tools.py b/paas2/esb/components/generic/templates/cmsi/toolkit/tools.py index eeb2fdad6..2ea755b19 100644 --- a/paas2/esb/components/generic/templates/cmsi/toolkit/tools.py +++ b/paas2/esb/components/generic/templates/cmsi/toolkit/tools.py @@ -16,6 +16,8 @@ import base64 from collections import OrderedDict, defaultdict +from django.utils.encoding import force_text + from common.errors import CommonAPIError default_nation_code = "86" @@ -159,7 +161,7 @@ def get_user_contact_with_username(username_list=None, contact_way="phone"): def get_base64_icon(path): with open(os.path.join(ICON_DIR, path), "rb") as f: - return base64.b64encode(f.read()) + return force_text(base64.b64encode(f.read())) def _get_users(usernames): diff --git a/paas2/release.md b/paas2/release.md index 5f5b8c47b..139df0fb4 100644 --- a/paas2/release.md +++ b/paas2/release.md @@ -1,5 +1,8 @@ Release Log =============================== +# 2.13.4 + - update: fix esb cmsi apis for python3/upgrade + # 2.13.3 - update: bugfix esb management for python3/upgrade