mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-11-02 15:31:03 +00:00
[GITEA] Use restricted sanitizer for repository description
- Currently the repository description uses the same sanitizer as a normal markdown document. This means that element such as heading and images are allowed and can be abused. - Create a minimal restricted sanitizer for the repository description, which only allows what the postprocessor currently allows, which are links and emojis. - Added unit testing. - Resolves https://codeberg.org/forgejo/forgejo/issues/1202 - Resolves https://codeberg.org/Codeberg/Community/issues/1122 (cherry picked from commita8afa4cd18) (cherry picked from commit0238587c51) (cherry picked from commita8c7bbf728) (cherry picked from commit80e05a8245) (cherry picked from commitf5af5050b3) (cherry picked from commit608f981e55) (cherry picked from commitf40cff9263) (cherry picked from commit5f113bb611)
This commit is contained in:
parent
661cf72db0
commit
7798a3d746
3 changed files with 56 additions and 5 deletions
|
|
@ -584,9 +584,9 @@ func (repo *Repository) DescriptionHTML(ctx context.Context) template.HTML {
|
|||
}, repo.Description)
|
||||
if err != nil {
|
||||
log.Error("Failed to render description for %s (ID: %d): %v", repo.Name, repo.ID, err)
|
||||
return template.HTML(markup.Sanitize(repo.Description))
|
||||
return template.HTML(markup.SanitizeDescription(repo.Description))
|
||||
}
|
||||
return template.HTML(markup.Sanitize(desc))
|
||||
return template.HTML(markup.SanitizeDescription(desc))
|
||||
}
|
||||
|
||||
// CloneLink represents different types of clone URLs of repository.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue