1
1
mirror of https://github.com/go-gitea/gitea synced 2025-08-26 03:18:28 +00:00

Handle push rejection message in Merge & Web Editor (#10373) (#10497)

Backport #10373

* Handle push rejection message in Merge

* Fix sanitize, adjust message handling

* Handle push-rejection in webeditor CRUD too

Co-authored-by: Lauris BH <lauris@nix.lv>

Co-authored-by: Lauris BH <lauris@nix.lv>
This commit is contained in:
zeripath
2020-02-27 13:37:11 +00:00
committed by GitHub
parent 93860af542
commit 5d11ccc9e1
8 changed files with 136 additions and 18 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)
}