mirror of https://github.com/gogs/gogs.git
pkg/markup: support data URL of base64 encoded images (#5391)
parent
db3f0048d8
commit
9079fb6a0d
|
@ -190,6 +190,12 @@ func wrapImgWithLink(urlPrefix string, buf *bytes.Buffer, token html.Token) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Skip in case the "src" is data url
|
||||||
|
if strings.HasPrefix(src, "data:") {
|
||||||
|
buf.WriteString(token.String())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Prepend repository base URL for internal links
|
// Prepend repository base URL for internal links
|
||||||
needPrepend := !isLink([]byte(src))
|
needPrepend := !isLink([]byte(src))
|
||||||
if needPrepend {
|
if needPrepend {
|
||||||
|
|
|
@ -36,6 +36,9 @@ func NewSanitizer() {
|
||||||
sanitizer.policy.AllowAttrs("type").Matching(regexp.MustCompile(`^checkbox$`)).OnElements("input")
|
sanitizer.policy.AllowAttrs("type").Matching(regexp.MustCompile(`^checkbox$`)).OnElements("input")
|
||||||
sanitizer.policy.AllowAttrs("checked", "disabled").OnElements("input")
|
sanitizer.policy.AllowAttrs("checked", "disabled").OnElements("input")
|
||||||
|
|
||||||
|
// Data URLs
|
||||||
|
sanitizer.policy.AllowURLSchemes("data")
|
||||||
|
|
||||||
// Custom URL-Schemes
|
// Custom URL-Schemes
|
||||||
sanitizer.policy.AllowURLSchemes(setting.Markdown.CustomURLSchemes...)
|
sanitizer.policy.AllowURLSchemes(setting.Markdown.CustomURLSchemes...)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue