mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-16 15:02:43 +00:00
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:
parent
2ed9ead6de
commit
089ccb0c80
8 changed files with 134 additions and 15 deletions
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue