From c9355516c55cd4201335c24f1a0e0da56d17dd9c Mon Sep 17 00:00:00 2001 From: Raghav Aggarwal Date: Wed, 31 Jul 2024 08:10:27 +0530 Subject: [PATCH] [MM-593] Added escape characters to user, repo and path in permalink preview (#803) * [MM-593] Added escape characters to user, repo and path in permalink preview * [MM-593] Fix lint errors --- server/plugin/utils.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server/plugin/utils.go b/server/plugin/utils.go index f2d434b65..4094c9801 100644 --- a/server/plugin/utils.go +++ b/server/plugin/utils.go @@ -300,6 +300,9 @@ func isInsideLink(msg string, index int) bool { // getCodeMarkdown returns the constructed markdown for a permalink. func getCodeMarkdown(user, repo, repoPath, word, lines string, isTruncated bool) string { + user = strings.ReplaceAll(user, "_", "\\_") + repo = strings.ReplaceAll(repo, "_", "\\_") + repoPath = strings.ReplaceAll(repoPath, "_", "\\_") final := fmt.Sprintf("\n[%s/%s/%s](%s)\n", user, repo, repoPath, word) ext := path.Ext(repoPath) // remove the preceding dot