mirror of
https://github.com/simple-login/app.git
synced 2025-02-24 15:53:22 +08:00
handle case msg is string in replace() (#1271)
should fix https://sentry.io/organizations/simplelogin/issues/3563106404/?alert_rule_id=2478639&alert_timestamp=1662404226476&alert_type=email&environment=production&project=1868546&referrer=alert_email
This commit is contained in:
parent
f47661c3d2
commit
753a28e886
2 changed files with 11 additions and 1 deletions
|
@ -994,7 +994,11 @@ def add_header(msg: Message, text_header, html_header=None) -> Message:
|
|||
return msg
|
||||
|
||||
|
||||
def replace(msg: Message, old, new) -> Message:
|
||||
def replace(msg: Union[Message, str], old, new) -> Union[Message, str]:
|
||||
if type(msg) is str:
|
||||
msg = msg.replace(old, new)
|
||||
return msg
|
||||
|
||||
content_type = msg.get_content_type()
|
||||
|
||||
if (
|
||||
|
|
|
@ -460,6 +460,12 @@ Content-Type: text/html; charset=us-ascii
|
|||
assert "old" not in new_msg.as_string()
|
||||
|
||||
|
||||
def test_replace_str():
|
||||
msg = "a string"
|
||||
new_msg = replace(msg, "a", "still a")
|
||||
assert new_msg == "still a string"
|
||||
|
||||
|
||||
def test_generate_reply_email(flask_client):
|
||||
user = create_new_user()
|
||||
reply_email = generate_reply_email("test@example.org", user)
|
||||
|
|
Loading…
Reference in a new issue