mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-11-03 08:02:36 +09:00 
			
		
		
		
	Compare commits
	
		
			13 Commits
		
	
	
		
			v1.10.0-de
			...
			v1.8.0-rc2
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					73ce02400c | ||
| 
						 | 
					197cbd674d | ||
| 
						 | 
					4a0f7c1eb4 | ||
| 
						 | 
					e54f7a708c | ||
| 
						 | 
					63f6764dce | ||
| 
						 | 
					0bf7ed55be | ||
| 
						 | 
					93e8174e4e | ||
| 
						 | 
					c5ec66a8a3 | ||
| 
						 | 
					b6fb082b78 | ||
| 
						 | 
					3ce195115b | ||
| 
						 | 
					00619a04f7 | ||
| 
						 | 
					16815306ad | ||
| 
						 | 
					3934d9cd2f | 
							
								
								
									
										64
									
								
								.drone.yml
									
									
									
									
									
								
							
							
						
						
									
										64
									
								
								.drone.yml
									
									
									
									
									
								
							@@ -211,41 +211,41 @@ pipeline:
 | 
			
		||||
    when:
 | 
			
		||||
      event: [ push, tag, pull_request ]
 | 
			
		||||
 | 
			
		||||
  bench-sqlite:
 | 
			
		||||
    image: golang:1.12
 | 
			
		||||
    pull: true
 | 
			
		||||
    group: bench
 | 
			
		||||
    commands:
 | 
			
		||||
      - make bench-sqlite
 | 
			
		||||
    when:
 | 
			
		||||
      event: [ tag ]
 | 
			
		||||
#  bench-sqlite:
 | 
			
		||||
#    image: golang:1.12
 | 
			
		||||
#    pull: true
 | 
			
		||||
#    group: bench
 | 
			
		||||
#    commands:
 | 
			
		||||
#      - make bench-sqlite
 | 
			
		||||
#    when:
 | 
			
		||||
#      event: [ tag ]
 | 
			
		||||
 | 
			
		||||
  bench-mysql:
 | 
			
		||||
    image: golang:1.12
 | 
			
		||||
    pull: true
 | 
			
		||||
    group: bench
 | 
			
		||||
    commands:
 | 
			
		||||
      - make bench-mysql
 | 
			
		||||
    when:
 | 
			
		||||
      event: [ tag ]
 | 
			
		||||
#  bench-mysql:
 | 
			
		||||
#    image: golang:1.12
 | 
			
		||||
#    pull: true
 | 
			
		||||
#    group: bench
 | 
			
		||||
#    commands:
 | 
			
		||||
#      - make bench-mysql
 | 
			
		||||
#    when:
 | 
			
		||||
#      event: [ tag ]
 | 
			
		||||
 | 
			
		||||
  bench-mssql:
 | 
			
		||||
    image: golang:1.12
 | 
			
		||||
    pull: true
 | 
			
		||||
    group: bench
 | 
			
		||||
    commands:
 | 
			
		||||
      - make bench-mssql
 | 
			
		||||
    when:
 | 
			
		||||
      event: [ tag ]
 | 
			
		||||
#  bench-mssql:
 | 
			
		||||
#    image: golang:1.12
 | 
			
		||||
#    pull: true
 | 
			
		||||
#    group: bench
 | 
			
		||||
#    commands:
 | 
			
		||||
#      - make bench-mssql
 | 
			
		||||
#    when:
 | 
			
		||||
#      event: [ tag ]
 | 
			
		||||
 | 
			
		||||
  bench-pgsql:
 | 
			
		||||
    image: golang:1.12
 | 
			
		||||
    pull: true
 | 
			
		||||
    group: bench
 | 
			
		||||
    commands:
 | 
			
		||||
      - make bench-pgsql
 | 
			
		||||
    when:
 | 
			
		||||
      event: [ tag ]
 | 
			
		||||
#  bench-pgsql:
 | 
			
		||||
#    image: golang:1.12
 | 
			
		||||
#    pull: true
 | 
			
		||||
#    group: bench
 | 
			
		||||
#    commands:
 | 
			
		||||
#      - make bench-pgsql
 | 
			
		||||
#    when:
 | 
			
		||||
#      event: [ tag ]
 | 
			
		||||
 | 
			
		||||
  generate-coverage:
 | 
			
		||||
    image: golang:1.12
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										20
									
								
								CHANGELOG.md
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								CHANGELOG.md
									
									
									
									
									
								
							@@ -4,6 +4,18 @@ This changelog goes through all the changes that have been made in each release
 | 
			
		||||
without substantial changes to our git log; to see the highlights of what has
 | 
			
		||||
been added to each release, please refer to the [blog](https://blog.gitea.io).
 | 
			
		||||
 | 
			
		||||
## [1.8.0-rc2](https://github.com/go-gitea/gitea/releases/tag/v1.8.0-rc2) - 2019-03-27
 | 
			
		||||
* BUGFIXES
 | 
			
		||||
  * Disable benchmarking during tag events on DroneIO (#6365) (#6366)
 | 
			
		||||
  * Make sure units of a team are returned (#6379) (#6381)
 | 
			
		||||
  * Don't Unescape redirect_to cookie value (#6399) (#6401)
 | 
			
		||||
  * Fix dump table name error and add some test for dump database (#6394) (#6402)
 | 
			
		||||
  * Fix migration v82 to ignore unsynced tags between database and git data; Add missing is_archived column on repository table (#6387) (#6403)
 | 
			
		||||
  * Display correct error for invalid mirror interval (#6414) (#6429)
 | 
			
		||||
  * Clean up ref name rules (#6437) (#6439)
 | 
			
		||||
  * Fix Hook & HookList in Swagger (#6432) (#6440)
 | 
			
		||||
  * Change order that PostProcess Processors are run (#6445) (#6447)
 | 
			
		||||
 | 
			
		||||
## [1.8.0-rc1](https://github.com/go-gitea/gitea/releases/tag/v1.8.0-rc1) - 2019-03-18
 | 
			
		||||
* BREAKING
 | 
			
		||||
  * Add "ghost" and "notifications" to list of reserved user names. (#6208)
 | 
			
		||||
@@ -210,7 +222,13 @@ been added to each release, please refer to the [blog](https://blog.gitea.io).
 | 
			
		||||
  * Add missing GET teams endpoints (#5382)
 | 
			
		||||
  * Migrate database if app.ini found (#5290)
 | 
			
		||||
 | 
			
		||||
## [1.7.4](https://github.com/go-gitea/gitea/releases/tag/v1.7.4) - 2019-03-12
 | 
			
		||||
## [1.7.5](https://github.com/go-gitea/gitea/releases/tag/v1.7.5) - 2019-03-27  
 | 
			
		||||
* BUGFIXES
 | 
			
		||||
  * Fix unitTypeCode not being used in accessLevelUnit (#6419) (#6423)
 | 
			
		||||
  * Fix bug where manifest.json was being requested without cookies and continuously creating new sessions (#6372) (#6383) 
 | 
			
		||||
  * Fix ParsePatch function to work with quoted diff --git strings (#6323) (#6332)
 | 
			
		||||
 | 
			
		||||
## [1.7.4](https://github.com/go-gitea/gitea/releases/tag/v1.7.4) - 2019-03-12  
 | 
			
		||||
* SECURITY
 | 
			
		||||
  * Fix potential XSS vulnerability in repository description. (#6306) (#6308)
 | 
			
		||||
* BUGFIXES
 | 
			
		||||
 
 | 
			
		||||
@@ -58,7 +58,7 @@ func TestCreateBranch(t *testing.T) {
 | 
			
		||||
			OldRefSubURL:   "branch/master",
 | 
			
		||||
			NewBranch:      "feature=test1",
 | 
			
		||||
			ExpectedStatus: http.StatusFound,
 | 
			
		||||
			FlashMessage:   i18n.Tr("en", "form.NewBranchName") + i18n.Tr("en", "form.git_ref_name_error"),
 | 
			
		||||
			FlashMessage:   i18n.Tr("en", "repo.branch.create_success", "feature=test1"),
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			OldRefSubURL:   "branch/master",
 | 
			
		||||
 
 | 
			
		||||
@@ -5,8 +5,11 @@
 | 
			
		||||
package migrations
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	"code.gitea.io/git"
 | 
			
		||||
	"code.gitea.io/gitea/models"
 | 
			
		||||
 | 
			
		||||
	"github.com/go-xorm/xorm"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
@@ -18,6 +21,17 @@ func fixReleaseSha1OnReleaseTable(x *xorm.Engine) error {
 | 
			
		||||
		TagName string
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	type Repository struct {
 | 
			
		||||
		ID      int64
 | 
			
		||||
		OwnerID int64
 | 
			
		||||
		Name    string
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	type User struct {
 | 
			
		||||
		ID   int64
 | 
			
		||||
		Name string
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Update release sha1
 | 
			
		||||
	const batchSize = 100
 | 
			
		||||
	sess := x.NewSession()
 | 
			
		||||
@@ -27,7 +41,8 @@ func fixReleaseSha1OnReleaseTable(x *xorm.Engine) error {
 | 
			
		||||
		err          error
 | 
			
		||||
		count        int
 | 
			
		||||
		gitRepoCache = make(map[int64]*git.Repository)
 | 
			
		||||
		repoCache    = make(map[int64]*models.Repository)
 | 
			
		||||
		repoCache    = make(map[int64]*Repository)
 | 
			
		||||
		userCache    = make(map[int64]*User)
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	if err = sess.Begin(); err != nil {
 | 
			
		||||
@@ -48,14 +63,31 @@ func fixReleaseSha1OnReleaseTable(x *xorm.Engine) error {
 | 
			
		||||
			if !ok {
 | 
			
		||||
				repo, ok := repoCache[release.RepoID]
 | 
			
		||||
				if !ok {
 | 
			
		||||
					repo, err = models.GetRepositoryByID(release.RepoID)
 | 
			
		||||
					repo = new(Repository)
 | 
			
		||||
					has, err := sess.ID(release.RepoID).Get(repo)
 | 
			
		||||
					if err != nil {
 | 
			
		||||
						return err
 | 
			
		||||
					} else if !has {
 | 
			
		||||
						return fmt.Errorf("Repository %d is not exist", release.RepoID)
 | 
			
		||||
					}
 | 
			
		||||
 | 
			
		||||
					repoCache[release.RepoID] = repo
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				gitRepo, err = git.OpenRepository(repo.RepoPath())
 | 
			
		||||
				user, ok := userCache[repo.OwnerID]
 | 
			
		||||
				if !ok {
 | 
			
		||||
					user = new(User)
 | 
			
		||||
					has, err := sess.ID(repo.OwnerID).Get(user)
 | 
			
		||||
					if err != nil {
 | 
			
		||||
						return err
 | 
			
		||||
					} else if !has {
 | 
			
		||||
						return fmt.Errorf("User %d is not exist", repo.OwnerID)
 | 
			
		||||
					}
 | 
			
		||||
 | 
			
		||||
					userCache[repo.OwnerID] = user
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				gitRepo, err = git.OpenRepository(models.RepoPath(user.Name, repo.Name))
 | 
			
		||||
				if err != nil {
 | 
			
		||||
					return err
 | 
			
		||||
				}
 | 
			
		||||
@@ -63,12 +95,14 @@ func fixReleaseSha1OnReleaseTable(x *xorm.Engine) error {
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			release.Sha1, err = gitRepo.GetTagCommitID(release.TagName)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
			if err != nil && !git.IsErrNotExist(err) {
 | 
			
		||||
				return err
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if _, err = sess.ID(release.ID).Cols("sha1").Update(release); err != nil {
 | 
			
		||||
				return err
 | 
			
		||||
			if err == nil {
 | 
			
		||||
				if _, err = sess.ID(release.ID).Cols("sha1").Update(release); err != nil {
 | 
			
		||||
					return err
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			count++
 | 
			
		||||
 
 | 
			
		||||
@@ -51,8 +51,9 @@ type Engine interface {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
	x      *xorm.Engine
 | 
			
		||||
	tables []interface{}
 | 
			
		||||
	x                  *xorm.Engine
 | 
			
		||||
	supportedDatabases = []string{"mysql", "postgres", "mssql"}
 | 
			
		||||
	tables             []interface{}
 | 
			
		||||
 | 
			
		||||
	// HasEngine specifies if we have a xorm.Engine
 | 
			
		||||
	HasEngine bool
 | 
			
		||||
@@ -350,7 +351,9 @@ func Ping() error {
 | 
			
		||||
func DumpDatabase(filePath string, dbType string) error {
 | 
			
		||||
	var tbs []*core.Table
 | 
			
		||||
	for _, t := range tables {
 | 
			
		||||
		tbs = append(tbs, x.TableInfo(t).Table)
 | 
			
		||||
		t := x.TableInfo(t)
 | 
			
		||||
		t.Table.Name = t.Name
 | 
			
		||||
		tbs = append(tbs, t.Table)
 | 
			
		||||
	}
 | 
			
		||||
	if len(dbType) > 0 {
 | 
			
		||||
		return x.DumpTablesToFile(tbs, filePath, core.DbType(dbType))
 | 
			
		||||
 
 | 
			
		||||
@@ -12,4 +12,5 @@ import (
 | 
			
		||||
 | 
			
		||||
func init() {
 | 
			
		||||
	EnableSQLite3 = true
 | 
			
		||||
	supportedDatabases = append(supportedDatabases, "sqlite3")
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -6,6 +6,9 @@
 | 
			
		||||
package models
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"io/ioutil"
 | 
			
		||||
	"os"
 | 
			
		||||
	"path/filepath"
 | 
			
		||||
	"testing"
 | 
			
		||||
 | 
			
		||||
	"github.com/stretchr/testify/assert"
 | 
			
		||||
@@ -93,3 +96,14 @@ func Test_getPostgreSQLConnectionString(t *testing.T) {
 | 
			
		||||
		assert.Equal(t, test.Output, connStr)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestDumpDatabase(t *testing.T) {
 | 
			
		||||
	assert.NoError(t, PrepareTestDatabase())
 | 
			
		||||
 | 
			
		||||
	dir, err := ioutil.TempDir(os.TempDir(), "dump")
 | 
			
		||||
	assert.NoError(t, err)
 | 
			
		||||
 | 
			
		||||
	for _, dbType := range supportedDatabases {
 | 
			
		||||
		assert.NoError(t, DumpDatabase(filepath.Join(dir, dbType+".sql"), dbType))
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -33,6 +33,11 @@ type Team struct {
 | 
			
		||||
	Units       []*TeamUnit `xorm:"-"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetUnits return a list of available units for a team
 | 
			
		||||
func (t *Team) GetUnits() error {
 | 
			
		||||
	return t.getUnits(x)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (t *Team) getUnits(e Engine) (err error) {
 | 
			
		||||
	if t.Units != nil {
 | 
			
		||||
		return nil
 | 
			
		||||
 
 | 
			
		||||
@@ -238,7 +238,7 @@ func accessLevelUnit(e Engine, user *User, repo *Repository, unitType UnitType)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return AccessModeNone, err
 | 
			
		||||
	}
 | 
			
		||||
	return perm.UnitAccessMode(UnitTypeCode), nil
 | 
			
		||||
	return perm.UnitAccessMode(unitType), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func hasAccessUnit(e Engine, user *User, repo *Repository, unitType UnitType, testMode AccessMode) (bool, error) {
 | 
			
		||||
 
 | 
			
		||||
@@ -152,15 +152,15 @@ func (p *postProcessError) Error() string {
 | 
			
		||||
type processor func(ctx *postProcessCtx, node *html.Node)
 | 
			
		||||
 | 
			
		||||
var defaultProcessors = []processor{
 | 
			
		||||
	mentionProcessor,
 | 
			
		||||
	shortLinkProcessor,
 | 
			
		||||
	fullIssuePatternProcessor,
 | 
			
		||||
	fullSha1PatternProcessor,
 | 
			
		||||
	shortLinkProcessor,
 | 
			
		||||
	linkProcessor,
 | 
			
		||||
	mentionProcessor,
 | 
			
		||||
	issueIndexPatternProcessor,
 | 
			
		||||
	crossReferenceIssueIndexPatternProcessor,
 | 
			
		||||
	fullSha1PatternProcessor,
 | 
			
		||||
	sha1CurrentPatternProcessor,
 | 
			
		||||
	emailAddressProcessor,
 | 
			
		||||
	linkProcessor,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type postProcessCtx struct {
 | 
			
		||||
@@ -194,14 +194,14 @@ func PostProcess(
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
var commitMessageProcessors = []processor{
 | 
			
		||||
	mentionProcessor,
 | 
			
		||||
	fullIssuePatternProcessor,
 | 
			
		||||
	fullSha1PatternProcessor,
 | 
			
		||||
	linkProcessor,
 | 
			
		||||
	mentionProcessor,
 | 
			
		||||
	issueIndexPatternProcessor,
 | 
			
		||||
	crossReferenceIssueIndexPatternProcessor,
 | 
			
		||||
	fullSha1PatternProcessor,
 | 
			
		||||
	sha1CurrentPatternProcessor,
 | 
			
		||||
	emailAddressProcessor,
 | 
			
		||||
	linkProcessor,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// RenderCommitMessage will use the same logic as PostProcess, but will disable
 | 
			
		||||
 
 | 
			
		||||
@@ -113,6 +113,12 @@ func TestRender_links(t *testing.T) {
 | 
			
		||||
	test(
 | 
			
		||||
		"https://foo_bar.example.com/",
 | 
			
		||||
		`<p><a href="https://foo_bar.example.com/" rel="nofollow">https://foo_bar.example.com/</a></p>`)
 | 
			
		||||
	test(
 | 
			
		||||
		"https://stackoverflow.com/questions/2896191/what-is-go-used-fore",
 | 
			
		||||
		`<p><a href="https://stackoverflow.com/questions/2896191/what-is-go-used-fore" rel="nofollow">https://stackoverflow.com/questions/2896191/what-is-go-used-fore</a></p>`)
 | 
			
		||||
	test(
 | 
			
		||||
		"https://username:password@gitea.com",
 | 
			
		||||
		`<p><a href="https://username:password@gitea.com" rel="nofollow">https://username:password@gitea.com</a></p>`)
 | 
			
		||||
 | 
			
		||||
	// Test that should *not* be turned into URL
 | 
			
		||||
	test(
 | 
			
		||||
 
 | 
			
		||||
@@ -19,7 +19,9 @@ const (
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
	// GitRefNamePattern is regular expression with unallowed characters in git reference name
 | 
			
		||||
	GitRefNamePattern = regexp.MustCompile("[^\\d\\w-_\\./]")
 | 
			
		||||
	// They cannot have ASCII control characters (i.e. bytes whose values are lower than \040, or \177 DEL), space, tilde ~, caret ^, or colon : anywhere.
 | 
			
		||||
	// They cannot have question-mark ?, asterisk *, or open bracket [ anywhere
 | 
			
		||||
	GitRefNamePattern = regexp.MustCompile(`[\000-\037\177 \\~^:?*[]+`)
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// AddBindingRules adds additional binding rules
 | 
			
		||||
@@ -44,7 +46,8 @@ func addGitRefNameBindingRule() {
 | 
			
		||||
			// Additional rules as described at https://www.kernel.org/pub/software/scm/git/docs/git-check-ref-format.html
 | 
			
		||||
			if strings.HasPrefix(str, "/") || strings.HasSuffix(str, "/") ||
 | 
			
		||||
				strings.HasSuffix(str, ".") || strings.Contains(str, "..") ||
 | 
			
		||||
				strings.Contains(str, "//") {
 | 
			
		||||
				strings.Contains(str, "//") || strings.Contains(str, "@{") ||
 | 
			
		||||
				str == "@" {
 | 
			
		||||
				errs.Add([]string{name}, ErrGitRefName, "GitRefName")
 | 
			
		||||
				return false, errs
 | 
			
		||||
			}
 | 
			
		||||
 
 | 
			
		||||
@@ -25,6 +25,13 @@ var gitRefNameValidationTestCases = []validationTestCase{
 | 
			
		||||
		},
 | 
			
		||||
		expectedErrors: binding.Errors{},
 | 
			
		||||
	},
 | 
			
		||||
	{
 | 
			
		||||
		description: "Reference name has allowed special characters",
 | 
			
		||||
		data: TestForm{
 | 
			
		||||
			BranchName: "debian/1%1.6.0-2",
 | 
			
		||||
		},
 | 
			
		||||
		expectedErrors: binding.Errors{},
 | 
			
		||||
	},
 | 
			
		||||
	{
 | 
			
		||||
		description: "Reference name contains backslash",
 | 
			
		||||
		data: TestForm{
 | 
			
		||||
@@ -129,6 +136,123 @@ var gitRefNameValidationTestCases = []validationTestCase{
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
	},
 | 
			
		||||
	{
 | 
			
		||||
		description: "Reference name is single @",
 | 
			
		||||
		data: TestForm{
 | 
			
		||||
			BranchName: "@",
 | 
			
		||||
		},
 | 
			
		||||
		expectedErrors: binding.Errors{
 | 
			
		||||
			binding.Error{
 | 
			
		||||
				FieldNames:     []string{"BranchName"},
 | 
			
		||||
				Classification: ErrGitRefName,
 | 
			
		||||
				Message:        "GitRefName",
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
	},
 | 
			
		||||
	{
 | 
			
		||||
		description: "Reference name has @{",
 | 
			
		||||
		data: TestForm{
 | 
			
		||||
			BranchName: "branch@{",
 | 
			
		||||
		},
 | 
			
		||||
		expectedErrors: binding.Errors{
 | 
			
		||||
			binding.Error{
 | 
			
		||||
				FieldNames:     []string{"BranchName"},
 | 
			
		||||
				Classification: ErrGitRefName,
 | 
			
		||||
				Message:        "GitRefName",
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
	},
 | 
			
		||||
	{
 | 
			
		||||
		description: "Reference name has unallowed special character ~",
 | 
			
		||||
		data: TestForm{
 | 
			
		||||
			BranchName: "~debian/1%1.6.0-2",
 | 
			
		||||
		},
 | 
			
		||||
		expectedErrors: binding.Errors{
 | 
			
		||||
			binding.Error{
 | 
			
		||||
				FieldNames:     []string{"BranchName"},
 | 
			
		||||
				Classification: ErrGitRefName,
 | 
			
		||||
				Message:        "GitRefName",
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
	},
 | 
			
		||||
	{
 | 
			
		||||
		description: "Reference name has unallowed special character *",
 | 
			
		||||
		data: TestForm{
 | 
			
		||||
			BranchName: "*debian/1%1.6.0-2",
 | 
			
		||||
		},
 | 
			
		||||
		expectedErrors: binding.Errors{
 | 
			
		||||
			binding.Error{
 | 
			
		||||
				FieldNames:     []string{"BranchName"},
 | 
			
		||||
				Classification: ErrGitRefName,
 | 
			
		||||
				Message:        "GitRefName",
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
	},
 | 
			
		||||
	{
 | 
			
		||||
		description: "Reference name has unallowed special character ?",
 | 
			
		||||
		data: TestForm{
 | 
			
		||||
			BranchName: "?debian/1%1.6.0-2",
 | 
			
		||||
		},
 | 
			
		||||
		expectedErrors: binding.Errors{
 | 
			
		||||
			binding.Error{
 | 
			
		||||
				FieldNames:     []string{"BranchName"},
 | 
			
		||||
				Classification: ErrGitRefName,
 | 
			
		||||
				Message:        "GitRefName",
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
	},
 | 
			
		||||
	{
 | 
			
		||||
		description: "Reference name has unallowed special character ^",
 | 
			
		||||
		data: TestForm{
 | 
			
		||||
			BranchName: "^debian/1%1.6.0-2",
 | 
			
		||||
		},
 | 
			
		||||
		expectedErrors: binding.Errors{
 | 
			
		||||
			binding.Error{
 | 
			
		||||
				FieldNames:     []string{"BranchName"},
 | 
			
		||||
				Classification: ErrGitRefName,
 | 
			
		||||
				Message:        "GitRefName",
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
	},
 | 
			
		||||
	{
 | 
			
		||||
		description: "Reference name has unallowed special character :",
 | 
			
		||||
		data: TestForm{
 | 
			
		||||
			BranchName: "debian:jessie",
 | 
			
		||||
		},
 | 
			
		||||
		expectedErrors: binding.Errors{
 | 
			
		||||
			binding.Error{
 | 
			
		||||
				FieldNames:     []string{"BranchName"},
 | 
			
		||||
				Classification: ErrGitRefName,
 | 
			
		||||
				Message:        "GitRefName",
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
	},
 | 
			
		||||
	{
 | 
			
		||||
		description: "Reference name has unallowed special character (whitespace)",
 | 
			
		||||
		data: TestForm{
 | 
			
		||||
			BranchName: "debian jessie",
 | 
			
		||||
		},
 | 
			
		||||
		expectedErrors: binding.Errors{
 | 
			
		||||
			binding.Error{
 | 
			
		||||
				FieldNames:     []string{"BranchName"},
 | 
			
		||||
				Classification: ErrGitRefName,
 | 
			
		||||
				Message:        "GitRefName",
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
	},
 | 
			
		||||
	{
 | 
			
		||||
		description: "Reference name has unallowed special character [",
 | 
			
		||||
		data: TestForm{
 | 
			
		||||
			BranchName: "debian[jessie",
 | 
			
		||||
		},
 | 
			
		||||
		expectedErrors: binding.Errors{
 | 
			
		||||
			binding.Error{
 | 
			
		||||
				FieldNames:     []string{"BranchName"},
 | 
			
		||||
				Classification: ErrGitRefName,
 | 
			
		||||
				Message:        "GitRefName",
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
	},
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func Test_GitRefNameValidation(t *testing.T) {
 | 
			
		||||
 
 | 
			
		||||
@@ -38,6 +38,11 @@ func ListTeams(ctx *context.APIContext) {
 | 
			
		||||
 | 
			
		||||
	apiTeams := make([]*api.Team, len(org.Teams))
 | 
			
		||||
	for i := range org.Teams {
 | 
			
		||||
		if err := org.Teams[i].GetUnits(); err != nil {
 | 
			
		||||
			ctx.Error(500, "GetUnits", err)
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		apiTeams[i] = convert.ToTeam(org.Teams[i])
 | 
			
		||||
	}
 | 
			
		||||
	ctx.JSON(200, apiTeams)
 | 
			
		||||
 
 | 
			
		||||
@@ -61,14 +61,14 @@ type swaggerResponseReferenceList struct {
 | 
			
		||||
// swagger:response Hook
 | 
			
		||||
type swaggerResponseHook struct {
 | 
			
		||||
	// in:body
 | 
			
		||||
	Body []api.Branch `json:"body"`
 | 
			
		||||
	Body api.Hook `json:"body"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// HookList
 | 
			
		||||
// swagger:response HookList
 | 
			
		||||
type swaggerResponseHookList struct {
 | 
			
		||||
	// in:body
 | 
			
		||||
	Body []api.Branch `json:"body"`
 | 
			
		||||
	Body []api.Hook `json:"body"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Release
 | 
			
		||||
 
 | 
			
		||||
@@ -14,6 +14,7 @@ import (
 | 
			
		||||
	"code.gitea.io/gitea/modules/base"
 | 
			
		||||
	"code.gitea.io/gitea/modules/context"
 | 
			
		||||
	"code.gitea.io/gitea/modules/log"
 | 
			
		||||
	"code.gitea.io/gitea/modules/util"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
@@ -250,5 +251,5 @@ func CreateBranch(ctx *context.Context, form auth.NewBranchForm) {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	ctx.Flash.Success(ctx.Tr("repo.branch.create_success", form.NewBranchName))
 | 
			
		||||
	ctx.Redirect(ctx.Repo.RepoLink + "/src/branch/" + form.NewBranchName)
 | 
			
		||||
	ctx.Redirect(ctx.Repo.RepoLink + "/src/branch/" + util.PathEscapeSegments(form.NewBranchName))
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -124,8 +124,13 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) {
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// This section doesn't require repo_name/RepoName to be set in the form, don't show it
 | 
			
		||||
		// as an error on the UI for this action
 | 
			
		||||
		ctx.Data["Err_RepoName"] = nil
 | 
			
		||||
 | 
			
		||||
		interval, err := time.ParseDuration(form.Interval)
 | 
			
		||||
		if err != nil || (interval != 0 && interval < setting.Mirror.MinInterval) {
 | 
			
		||||
			ctx.Data["Err_Interval"] = true
 | 
			
		||||
			ctx.RenderWithErr(ctx.Tr("repo.mirror_interval_invalid"), tplSettingsOptions, &form)
 | 
			
		||||
		} else {
 | 
			
		||||
			ctx.Repo.Mirror.EnablePrune = form.EnablePrune
 | 
			
		||||
@@ -136,6 +141,7 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) {
 | 
			
		||||
				ctx.Repo.Mirror.NextUpdateUnix = 0
 | 
			
		||||
			}
 | 
			
		||||
			if err := models.UpdateMirror(ctx.Repo.Mirror); err != nil {
 | 
			
		||||
				ctx.Data["Err_Interval"] = true
 | 
			
		||||
				ctx.RenderWithErr(ctx.Tr("repo.mirror_interval_invalid"), tplSettingsOptions, &form)
 | 
			
		||||
				return
 | 
			
		||||
			}
 | 
			
		||||
@@ -161,6 +167,10 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) {
 | 
			
		||||
	case "advanced":
 | 
			
		||||
		var units []models.RepoUnit
 | 
			
		||||
 | 
			
		||||
		// This section doesn't require repo_name/RepoName to be set in the form, don't show it
 | 
			
		||||
		// as an error on the UI for this action
 | 
			
		||||
		ctx.Data["Err_RepoName"] = nil
 | 
			
		||||
 | 
			
		||||
		for _, tp := range models.MustRepoUnits {
 | 
			
		||||
			units = append(units, models.RepoUnit{
 | 
			
		||||
				RepoID: repo.ID,
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,6 @@ import (
 | 
			
		||||
	"errors"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"net/url"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"code.gitea.io/gitea/models"
 | 
			
		||||
@@ -96,7 +95,7 @@ func checkAutoLogin(ctx *context.Context) bool {
 | 
			
		||||
	if len(redirectTo) > 0 {
 | 
			
		||||
		ctx.SetCookie("redirect_to", redirectTo, 0, setting.AppSubURL, "", setting.SessionConfig.Secure, true)
 | 
			
		||||
	} else {
 | 
			
		||||
		redirectTo, _ = url.QueryUnescape(ctx.GetCookie("redirect_to"))
 | 
			
		||||
		redirectTo = ctx.GetCookie("redirect_to")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if isSucceed {
 | 
			
		||||
@@ -496,7 +495,7 @@ func handleSignInFull(ctx *context.Context, u *models.User, remember bool, obeyR
 | 
			
		||||
		return setting.AppSubURL + "/"
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if redirectTo, _ := url.QueryUnescape(ctx.GetCookie("redirect_to")); len(redirectTo) > 0 && !util.IsExternalURL(redirectTo) {
 | 
			
		||||
	if redirectTo := ctx.GetCookie("redirect_to"); len(redirectTo) > 0 && !util.IsExternalURL(redirectTo) {
 | 
			
		||||
		ctx.SetCookie("redirect_to", "", -1, setting.AppSubURL, "", setting.SessionConfig.Secure, true)
 | 
			
		||||
		if obeyRedirect {
 | 
			
		||||
			ctx.RedirectToFirst(redirectTo)
 | 
			
		||||
@@ -587,7 +586,7 @@ func handleOAuth2SignIn(u *models.User, gothUser goth.User, ctx *context.Context
 | 
			
		||||
				return
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if redirectTo, _ := url.QueryUnescape(ctx.GetCookie("redirect_to")); len(redirectTo) > 0 {
 | 
			
		||||
			if redirectTo := ctx.GetCookie("redirect_to"); len(redirectTo) > 0 {
 | 
			
		||||
				ctx.SetCookie("redirect_to", "", -1, setting.AppSubURL, "", setting.SessionConfig.Secure, true)
 | 
			
		||||
				ctx.RedirectToFirst(redirectTo)
 | 
			
		||||
				return
 | 
			
		||||
@@ -1298,7 +1297,7 @@ func MustChangePasswordPost(ctx *context.Context, cpt *captcha.Captcha, form aut
 | 
			
		||||
 | 
			
		||||
	log.Trace("User updated password: %s", u.Name)
 | 
			
		||||
 | 
			
		||||
	if redirectTo, _ := url.QueryUnescape(ctx.GetCookie("redirect_to")); len(redirectTo) > 0 && !util.IsExternalURL(redirectTo) {
 | 
			
		||||
	if redirectTo := ctx.GetCookie("redirect_to"); len(redirectTo) > 0 && !util.IsExternalURL(redirectTo) {
 | 
			
		||||
		ctx.SetCookie("redirect_to", "", -1, setting.AppSubURL)
 | 
			
		||||
		ctx.RedirectToFirst(redirectTo)
 | 
			
		||||
		return
 | 
			
		||||
 
 | 
			
		||||
@@ -47,7 +47,7 @@ func SignInOpenID(ctx *context.Context) {
 | 
			
		||||
	if len(redirectTo) > 0 {
 | 
			
		||||
		ctx.SetCookie("redirect_to", redirectTo, 0, setting.AppSubURL, "", setting.SessionConfig.Secure, true)
 | 
			
		||||
	} else {
 | 
			
		||||
		redirectTo, _ = url.QueryUnescape(ctx.GetCookie("redirect_to"))
 | 
			
		||||
		redirectTo = ctx.GetCookie("redirect_to")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if isSucceed {
 | 
			
		||||
 
 | 
			
		||||
@@ -5,7 +5,7 @@
 | 
			
		||||
	<meta name="viewport" content="width=device-width, initial-scale=1">
 | 
			
		||||
	<meta http-equiv="x-ua-compatible" content="ie=edge">
 | 
			
		||||
	<title>{{if .Title}}{{.Title}} - {{end}}{{AppName}}</title>
 | 
			
		||||
	<link rel="manifest" href="{{AppSubUrl}}/manifest.json">
 | 
			
		||||
	<link rel="manifest" href="{{AppSubUrl}}/manifest.json" crossorigin="use-credentials">
 | 
			
		||||
 | 
			
		||||
	<script>
 | 
			
		||||
		if ('serviceWorker' in navigator) {
 | 
			
		||||
 
 | 
			
		||||
@@ -7556,6 +7556,50 @@
 | 
			
		||||
      },
 | 
			
		||||
      "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea"
 | 
			
		||||
    },
 | 
			
		||||
    "Hook": {
 | 
			
		||||
      "description": "Hook a hook is a web hook when one repository changed",
 | 
			
		||||
      "type": "object",
 | 
			
		||||
      "properties": {
 | 
			
		||||
        "active": {
 | 
			
		||||
          "type": "boolean",
 | 
			
		||||
          "x-go-name": "Active"
 | 
			
		||||
        },
 | 
			
		||||
        "config": {
 | 
			
		||||
          "type": "object",
 | 
			
		||||
          "additionalProperties": {
 | 
			
		||||
            "type": "string"
 | 
			
		||||
          },
 | 
			
		||||
          "x-go-name": "Config"
 | 
			
		||||
        },
 | 
			
		||||
        "created_at": {
 | 
			
		||||
          "type": "string",
 | 
			
		||||
          "format": "date-time",
 | 
			
		||||
          "x-go-name": "Created"
 | 
			
		||||
        },
 | 
			
		||||
        "events": {
 | 
			
		||||
          "type": "array",
 | 
			
		||||
          "items": {
 | 
			
		||||
            "type": "string"
 | 
			
		||||
          },
 | 
			
		||||
          "x-go-name": "Events"
 | 
			
		||||
        },
 | 
			
		||||
        "id": {
 | 
			
		||||
          "type": "integer",
 | 
			
		||||
          "format": "int64",
 | 
			
		||||
          "x-go-name": "ID"
 | 
			
		||||
        },
 | 
			
		||||
        "type": {
 | 
			
		||||
          "type": "string",
 | 
			
		||||
          "x-go-name": "Type"
 | 
			
		||||
        },
 | 
			
		||||
        "updated_at": {
 | 
			
		||||
          "type": "string",
 | 
			
		||||
          "format": "date-time",
 | 
			
		||||
          "x-go-name": "Updated"
 | 
			
		||||
        }
 | 
			
		||||
      },
 | 
			
		||||
      "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea"
 | 
			
		||||
    },
 | 
			
		||||
    "Issue": {
 | 
			
		||||
      "description": "Issue represents an issue in a repository",
 | 
			
		||||
      "type": "object",
 | 
			
		||||
@@ -8824,10 +8868,7 @@
 | 
			
		||||
    "Hook": {
 | 
			
		||||
      "description": "Hook",
 | 
			
		||||
      "schema": {
 | 
			
		||||
        "type": "array",
 | 
			
		||||
        "items": {
 | 
			
		||||
          "$ref": "#/definitions/Branch"
 | 
			
		||||
        }
 | 
			
		||||
        "$ref": "#/definitions/Hook"
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "HookList": {
 | 
			
		||||
@@ -8835,7 +8876,7 @@
 | 
			
		||||
      "schema": {
 | 
			
		||||
        "type": "array",
 | 
			
		||||
        "items": {
 | 
			
		||||
          "$ref": "#/definitions/Branch"
 | 
			
		||||
          "$ref": "#/definitions/Hook"
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user