Skip to content

Commit 699820a

Browse files
lunnyGiteaBot
authored andcommitted
Fix dump release asset bug (go-gitea#36799)
1 parent 0f55eff commit 699820a

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

services/migrations/dump.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,12 +288,13 @@ func (g *RepositoryDumper) CreateLabels(_ context.Context, labels ...*base.Label
288288
func (g *RepositoryDumper) CreateReleases(_ context.Context, releases ...*base.Release) error {
289289
if g.opts.ReleaseAssets {
290290
for _, release := range releases {
291-
attachDir := filepath.Join("release_assets", release.TagName)
291+
attachDir := filepath.Join("release_assets", uuid.New().String())
292292
if err := os.MkdirAll(filepath.Join(g.baseDir, attachDir), os.ModePerm); err != nil {
293293
return err
294294
}
295295
for _, asset := range release.Assets {
296-
attachLocalPath := filepath.Join(attachDir, asset.Name)
296+
// we cannot use asset.Name because it might contains special characters.
297+
attachLocalPath := filepath.Join(attachDir, uuid.New().String())
297298

298299
// SECURITY: We cannot check the DownloadURL and DownloadFunc are safe here
299300
// ... we must assume that they are safe and simply download the attachment

0 commit comments

Comments
 (0)