Navigation Menu

Skip to content

Commit

Permalink
update user about me markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
aichy126 committed Feb 22, 2023
1 parent 383cc10 commit 71a4cda
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/schema/user_schema.go
Expand Up @@ -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
}

Expand Down
11 changes: 11 additions & 0 deletions pkg/converter/markdown.go
Expand Up @@ -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 {
}

Expand Down

0 comments on commit 71a4cda

Please sign in to comment.