mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-02 13:42:25 -06:00
[bugfix] Use custom bluemonday policy to disallow inline img tags (#2100)
This commit is contained in:
parent
3aedd937c3
commit
dc96562b40
17 changed files with 243 additions and 78 deletions
|
|
@ -18,6 +18,7 @@
|
|||
package text
|
||||
|
||||
import (
|
||||
"github.com/superseriousbusiness/gotosocial/internal/log"
|
||||
"github.com/tdewolff/minify/v2"
|
||||
"github.com/tdewolff/minify/v2/html"
|
||||
)
|
||||
|
|
@ -31,3 +32,23 @@ var m = func() *minify.M {
|
|||
})
|
||||
return m
|
||||
}()
|
||||
|
||||
// MinifyHTML minifies the given string
|
||||
// under the assumption that it's HTML.
|
||||
//
|
||||
// If input is not HTML encoded, this
|
||||
// function will try to do minimization
|
||||
// anyway, but this may produce unexpected
|
||||
// results.
|
||||
//
|
||||
// If an error occurs during minimization,
|
||||
// it will be logged and the original string
|
||||
// returned unmodified.
|
||||
func MinifyHTML(in string) string {
|
||||
out, err := m.String("text/html", in)
|
||||
if err != nil {
|
||||
log.Error(nil, err)
|
||||
}
|
||||
|
||||
return out
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue