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

editor_test.go 717 B

123456789101112131415161718192021222324252627282930
  1. // Copyright 2018 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package repo
  5. import (
  6. "testing"
  7. "code.gitea.io/gitea/models"
  8. "github.com/stretchr/testify/assert"
  9. )
  10. func TestCleanUploadName(t *testing.T) {
  11. models.PrepareTestEnv(t)
  12. var kases = map[string]string{
  13. ".git/refs/master": "git/refs/master",
  14. "/root/abc": "root/abc",
  15. "./../../abc": "abc",
  16. "a/../.git": "a/.git",
  17. "a/../../../abc": "a/abc",
  18. "../../../acd": "acd",
  19. "../../.git/abc": "git/abc",
  20. "..\\..\\.git/abc": "git/abc",
  21. }
  22. for k, v := range kases {
  23. assert.EqualValues(t, v, cleanUploadFileName(k))
  24. }
  25. }