diff --git a/llvm/utils/git/github-automation.py b/llvm/utils/git/github-automation.py
index eac5816b5499f..5c90ca8bb7150 100755
--- a/llvm/utils/git/github-automation.py
+++ b/llvm/utils/git/github-automation.py
@@ -47,6 +47,16 @@ def _get_curent_team(team_name, teams) -> Optional[github.Team.Team]:
return None
+def escape_description(str):
+ # https://github.com/github/markup/issues/1168#issuecomment-494946168
+ str = html.escape(str, False)
+ # '@' followed by alphanum is a user name
+ str = re.sub("@(?=\w+)", "@", str)
+ # '#' followed by digits is considered an issue number
+ str = re.sub("#(?=\d+\s)", "#", str)
+ return str
+
+
class IssueSubscriber:
@property
def team_name(self) -> str:
@@ -67,12 +77,15 @@ def run(self) -> bool:
if team.slug == "issue-subscribers-good-first-issue":
comment = "{}\n".format(beginner_comment)
- comment = (
- f"@llvm/{team.slug}"
- + "\n\n
\n" + html.escape(patch) - # GitHub limits comments to 65,536 characters, let's limit the diff to 20kB. - DIFF_LIMIT = 20 * 1024 patch_link = f"Full diff: {self.pr.diff_url}\n" if len(patch) > DIFF_LIMIT: patch_link = f"\nPatch is {human_readable_size(len(patch))}, truncated to {human_readable_size(DIFF_LIMIT)} below, full version: {self.pr.diff_url}\n" - diff_stats = diff_stats[0:DIFF_LIMIT] + "...\n" + patch = patch[0:DIFF_LIMIT] + "...\n[truncated]\n" team_mention = "@llvm/{}".format(team.slug) - body = self.pr.body + body = escape_description(self.pr.body) + # Note: the comment is in markdown and the code below + # is sensible to line break comment = f""" {self.COMMENT_TAG} {team_mention} - +\n" - diff_stats += "