diff options
author | zeripath <art27@cantab.net> | 2020-02-22 13:08:48 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-22 15:08:48 +0200 |
commit | 089ccb0c80050efc8c3afef2402ea4f4a5ed250e (patch) | |
tree | 4ff172035ffd0a9a5263dedc051a91ab24c33fa6 /routers/utils | |
parent | 2ed9ead6dea29f9e006fa1831892c9c239f4bd70 (diff) | |
download | gitea-089ccb0c80050efc8c3afef2402ea4f4a5ed250e.tar.gz gitea-089ccb0c80050efc8c3afef2402ea4f4a5ed250e.zip |
Handle push rejection message in Merge & Web Editor (#10373)
* Handle push rejection message in Merge
* placate golangci-lint
* Fix sanitize, adjust message handling
* oops
* Oops
* Handle push-rejection in webeditor CRUD too
* Apply suggestions from code review
Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'routers/utils')
-rw-r--r-- | routers/utils/utils.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/routers/utils/utils.go b/routers/utils/utils.go index 7c90fd7048..64b132ff3e 100644 --- a/routers/utils/utils.go +++ b/routers/utils/utils.go @@ -5,6 +5,7 @@ package utils import ( + "html" "strings" ) @@ -34,3 +35,14 @@ func IsValidSlackChannel(channelName string) bool { return true } + +// SanitizeFlashErrorString will sanitize a flash error string +func SanitizeFlashErrorString(x string) string { + runes := []rune(x) + + if len(runes) > 512 { + x = "..." + string(runes[len(runes)-512:]) + } + + return strings.Replace(html.EscapeString(x), "\n", "<br>", -1) +} |