You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright 2023 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package fuzz
  4. import (
  5. "bytes"
  6. "context"
  7. "io"
  8. "testing"
  9. "code.gitea.io/gitea/modules/markup"
  10. "code.gitea.io/gitea/modules/markup/markdown"
  11. "code.gitea.io/gitea/modules/setting"
  12. )
  13. var renderContext = markup.RenderContext{
  14. Ctx: context.Background(),
  15. URLPrefix: "https://example.com/go-gitea/gitea",
  16. Metas: map[string]string{
  17. "user": "go-gitea",
  18. "repo": "gitea",
  19. },
  20. }
  21. func FuzzMarkdownRenderRaw(f *testing.F) {
  22. f.Fuzz(func(t *testing.T, data []byte) {
  23. setting.AppURL = "http://localhost:3000/"
  24. markdown.RenderRaw(&renderContext, bytes.NewReader(data), io.Discard)
  25. })
  26. }
  27. func FuzzMarkupPostProcess(f *testing.F) {
  28. f.Fuzz(func(t *testing.T, data []byte) {
  29. setting.AppURL = "http://localhost:3000/"
  30. markup.PostProcess(&renderContext, bytes.NewReader(data), io.Discard)
  31. })
  32. }