Skip to content

Commit 7011571

Browse files
Taka NishidaGitLab
authored andcommitted
Merge branch 'fix-non-latin-1-error-when-uploading-artifacts' into 'main'
Fix non-latin-1 string error when uploading artifact See merge request https://gitlab.com/gitlab-org/gitlab-runner/-/merge_requests/6487 Merged-by: Taka Nishida <tnishida@gitlab.com> Approved-by: Igor <iwiedler@gitlab.com> Approved-by: Axel von Bertoldi <avonbertoldi@gitlab.com>
2 parents d411160 + 86c126f commit 7011571

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

helpers/archives/gzip_create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func writeGzipFile(w io.Writer, fileName string, fileInfo os.FileInfo) error {
2727
}
2828

2929
gz := gzip.NewWriter(w)
30-
gz.Header.Name = fileInfo.Name()
30+
gz.Header.Name = sanitizePath(fileInfo.Name())
3131
gz.Header.Comment = sanitizePath(fileName)
3232
gz.Header.ModTime = fileInfo.ModTime()
3333

helpers/archives/gzip_create_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,13 @@ func TestGzipSanitization(t *testing.T) {
138138
content: []byte("content"),
139139
needsEncoding: true,
140140
},
141+
{
142+
name: "with non-ASCII filename",
143+
dir: "test",
144+
file: "TEST-日本語テスト.txt",
145+
content: []byte("content"),
146+
needsEncoding: true,
147+
},
141148
}
142149

143150
for _, tt := range tests {

0 commit comments

Comments
 (0)