Skip to content

Commit c0c2b06

Browse files
committed
fix: percent-encode message-id in built activity url (CM-1318)
Signed-off-by: Uroš Marolt <uros@marolt.me>
1 parent 929bdfc commit c0c2b06

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

services/apps/mailing_list_integration/src/crowdmail/services/parse/noteren.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import re
1919
import subprocess
2020
import sys
21+
import urllib.parse
2122

2223
from crowdmail.enums import ActivityType
2324
from crowdmail.errors import CommandExecutionError
@@ -364,7 +365,7 @@ def parse_email(
364365
"channel": channel,
365366
"title": subject,
366367
"body": json_body,
367-
"url": source.rstrip("/") + "/r/" + msgid,
368+
"url": source.rstrip("/") + "/r/" + urllib.parse.quote(msgid, safe=""),
368369
"isContribution": True,
369370
"type": ActivityType.MESSAGE,
370371
# Matches groupsio's Groupsio_GRID MESSAGE score (services/libs/integrations/src/integrations/groupsio/grid.ts)

services/apps/mailing_list_integration/src/test/test_noteren.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -854,14 +854,14 @@ def test_parse_email_url_contains_message_id():
854854
b"body\n"
855855
)
856856
parsed = _parse_email(raw, "src", "chan", "c1", "b1")
857-
assert parsed["activityData"]["url"] == "src/r/unique-id@example.com"
857+
assert parsed["activityData"]["url"] == "src/r/unique-id%40example.com"
858858

859859

860860
def test_parse_email_url_with_no_message_id():
861861
"""When Message-ID is absent the url must embed the synthetic channel:git_id id."""
862862
raw = b"From: A <a@example.com>\nSubject: s\nDate: Mon, 1 Jan 2024 12:00:00 +0000\n\nbody\n"
863863
parsed = _parse_email(raw, "src", "chan", "c1", "b1")
864-
assert parsed["activityData"]["url"] == "src/r/chan:c1"
864+
assert parsed["activityData"]["url"] == "src/r/chan%3Ac1"
865865

866866

867867
def test_parse_email_result_structure():

0 commit comments

Comments
 (0)