diff options
author | zeripath <art27@cantab.net> | 2019-12-31 01:53:28 +0000 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2019-12-31 03:53:28 +0200 |
commit | 27757714d0420192e6139d1e4206446dcefe6531 (patch) | |
tree | d237deeb48315f1465dbd915b65f95973c4cbbe9 /modules/markup/sanitizer.go | |
parent | 0c07f1de5b8cf7b9f9f607aae76a53c99aeb2c04 (diff) | |
download | gitea-27757714d0420192e6139d1e4206446dcefe6531.tar.gz gitea-27757714d0420192e6139d1e4206446dcefe6531.zip |
Change markdown rendering from blackfriday to goldmark (#9533)
* Move to goldmark
Markdown rendering moved from blackfriday to the goldmark.
Multiple subtle changes required to the goldmark extensions to keep
current rendering and defaults.
Can go further with goldmark linkify and have this work within markdown
rendering making the link processor unnecessary.
Need to think about how to go about allowing extensions - at present it
seems that these would be hard to do without recompilation.
* linter fixes
Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'modules/markup/sanitizer.go')
-rw-r--r-- | modules/markup/sanitizer.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/modules/markup/sanitizer.go b/modules/markup/sanitizer.go index f7789a9e56..d135d41966 100644 --- a/modules/markup/sanitizer.go +++ b/modules/markup/sanitizer.go @@ -6,6 +6,8 @@ package markup import ( + "bytes" + "io" "regexp" "sync" @@ -67,6 +69,12 @@ func Sanitize(s string) string { return sanitizer.policy.Sanitize(s) } +// SanitizeReader sanitizes a Reader +func SanitizeReader(r io.Reader) *bytes.Buffer { + NewSanitizer() + return sanitizer.policy.SanitizeReader(r) +} + // SanitizeBytes takes a []byte slice that contains a HTML fragment or document and applies policy whitelist. func SanitizeBytes(b []byte) []byte { if len(b) == 0 { |