mirror of https://gitee.com/answerdev/answer.git
Merge branch 'feat/1.0.6/fixbug' into test
This commit is contained in:
commit
010cd7501d
|
@ -309,7 +309,7 @@ func (req *UpdateInfoRequest) Check() (errFields []*validator.FormErrorField, er
|
|||
return errFields, errors.BadRequest(reason.UsernameInvalid)
|
||||
}
|
||||
}
|
||||
req.BioHTML = converter.Markdown2HTML(req.Bio)
|
||||
req.BioHTML = converter.Markdown2BasicHTML(req.Bio)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,17 @@ func Markdown2HTML(source string) string {
|
|||
return buf.String()
|
||||
}
|
||||
|
||||
// Markdown2BasicHTML convert markdown to html ,Only basic syntax can be used
|
||||
func Markdown2BasicHTML(source string) string {
|
||||
content := Markdown2HTML(source)
|
||||
filter := bluemonday.NewPolicy()
|
||||
filter.AllowElements("p", "b", "br")
|
||||
filter.AllowAttrs("src").OnElements("img")
|
||||
filter.AddSpaceWhenStrippingTag(true)
|
||||
content = filter.Sanitize(content)
|
||||
return content
|
||||
}
|
||||
|
||||
type DangerousHTMLFilterExtension struct {
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue