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>
This commit is contained in:
zeripath 2020-02-22 13:08:48 +00:00 committed by GitHub
parent 2ed9ead6de
commit 089ccb0c80
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 134 additions and 15 deletions

View file

@ -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)
}