Skip to content

Commit a915e5a

Browse files
committed
slack: escape text in msg first line
1 parent 8e6f4ef commit a915e5a

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

lib/slack.ml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ let empty_attachments =
2525

2626
let mrkdwn_of_markdown str = String.strip @@ Mrkdwn.mrkdwn_of_markdown str
2727
let mrkdwn_of_markdown_opt = Option.map ~f:mrkdwn_of_markdown
28+
let escape = Mrkdwn.escape_mrkdwn
2829

2930
let show_labels = function
3031
| [] -> None
@@ -49,7 +50,7 @@ let generate_pull_request_notification notification channel =
4950
)
5051
in
5152
let summary =
52-
sprintf "<%s|[%s]> Pull request #%d <%s|%s> %s by *%s*" repository.url repository.full_name number html_url title
53+
sprintf "<%s|[%s]> Pull request #%d <%s|%s> %s by *%s*" repository.url repository.full_name number html_url (escape title)
5354
action sender.login
5455
in
5556
{
@@ -88,7 +89,7 @@ let generate_pr_review_notification notification channel =
8889
in
8990
let summary =
9091
sprintf "<%s|[%s]> *%s* <%s|%s> #%d <%s|%s>" repository.url repository.full_name sender.login review.html_url
91-
action_str number html_url title
92+
action_str number html_url (escape title)
9293
in
9394
{
9495
channel;
@@ -120,7 +121,7 @@ let generate_pr_review_comment_notification notification channel =
120121
in
121122
let summary =
122123
sprintf "<%s|[%s]> *%s* %s on #%d <%s|%s>" repository.url repository.full_name sender.login action_str number
123-
html_url title
124+
html_url (escape title)
124125
in
125126
let file =
126127
match comment.path with
@@ -160,7 +161,7 @@ let generate_issue_notification notification channel =
160161
)
161162
in
162163
let summary =
163-
sprintf "<%s|[%s]> Issue #%d <%s|%s> %s by *%s*" repository.url repository.full_name number html_url title action
164+
sprintf "<%s|[%s]> Issue #%d <%s|%s> %s by *%s*" repository.url repository.full_name number html_url (escape title) action
164165
sender.login
165166
in
166167
{
@@ -194,7 +195,7 @@ let generate_issue_comment_notification notification channel =
194195
in
195196
let summary =
196197
sprintf "<%s|[%s]> *%s* <%s|%s> on #%d <%s|%s>" repository.url repository.full_name sender.login comment.html_url
197-
action_str number issue.html_url title
198+
action_str number issue.html_url (escape title)
198199
in
199200
{
200201
channel;
@@ -342,7 +343,7 @@ let generate_commit_comment_notification api_commit notification channel =
342343
in
343344
let summary =
344345
sprintf "<%s|[%s]> *%s* commented on `<%s|%s>` %s" repository.url repository.full_name sender.login comment.html_url
345-
(git_short_sha_hash commit_id) (first_line commit.message)
346+
(git_short_sha_hash commit_id) (first_line (escape commit.message))
346347
in
347348
let path =
348349
match comment.path with

0 commit comments

Comments
 (0)