diff options
author | zeripath <art27@cantab.net> | 2021-03-08 13:50:57 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-08 14:50:57 +0100 |
commit | 906ecfd173a70650250288d7b0a6730aaeddd14f (patch) | |
tree | 1d79254d2de50bb73c820eb83d4c8f9b42358b06 | |
parent | 75496b9ff507ca5e9b7665f888f1156485e6532d (diff) | |
download | gitea-906ecfd173a70650250288d7b0a6730aaeddd14f.tar.gz gitea-906ecfd173a70650250288d7b0a6730aaeddd14f.zip |
Re-enable import local paths after reversion from #13610 (#14925) (#14927)
Backport #14925
PR #13610 unfortunately disabled importing repositories from local paths.
This PR restores this functionality.
Fix #14700
Signed-off-by: Andrew Thornton <art27@cantab.net>
-rw-r--r-- | modules/migrations/migrate.go | 7 | ||||
-rw-r--r-- | modules/migrations/migrate_test.go | 12 |
2 files changed, 19 insertions, 0 deletions
diff --git a/modules/migrations/migrate.go b/modules/migrations/migrate.go index b3ecb8114a..bb1b572e74 100644 --- a/modules/migrations/migrate.go +++ b/modules/migrations/migrate.go @@ -52,6 +52,13 @@ func isMigrateURLAllowed(remoteURL string) error { } } + if u.Host == "" { + if !setting.ImportLocalPaths { + return &models.ErrMigrationNotAllowed{Host: "<LOCAL_FILESYSTEM>"} + } + return nil + } + if !setting.Migrations.AllowLocalNetworks { addrList, err := net.LookupIP(strings.Split(u.Host, ":")[0]) if err != nil { diff --git a/modules/migrations/migrate_test.go b/modules/migrations/migrate_test.go index 3bad5cfd73..e8b71bb325 100644 --- a/modules/migrations/migrate_test.go +++ b/modules/migrations/migrate_test.go @@ -31,4 +31,16 @@ func TestMigrateWhiteBlocklist(t *testing.T) { err = isMigrateURLAllowed("https://github.com/go-gitea/gitea.git") assert.Error(t, err) + + old := setting.ImportLocalPaths + setting.ImportLocalPaths = false + + err = isMigrateURLAllowed("/home/foo/bar/goo") + assert.Error(t, err) + + setting.ImportLocalPaths = true + err = isMigrateURLAllowed("/home/foo/bar/goo") + assert.NoError(t, err) + + setting.ImportLocalPaths = old } |