gitea源码

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