Skip to content

Commit c7770fa

Browse files
zeripathlunnylafriks
authored
Use path not filepath in template filenames (#21993) (#22022)
Backport #21993 Paths in git are always separated by `/` not `\` - therefore we should `path` and not `filepath` Fix #21987 Signed-off-by: Andrew Thornton <[email protected]> Co-authored-by: Lunny Xiao <[email protected]> Co-authored-by: Lauris BH <[email protected]>
1 parent da956b8 commit c7770fa

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Diff for: modules/issue/template/unmarshal.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ package template
77
import (
88
"fmt"
99
"io"
10-
"path/filepath"
10+
"path"
1111
"strconv"
1212

1313
"code.gitea.io/gitea/modules/git"
@@ -44,7 +44,7 @@ func Unmarshal(filename string, content []byte) (*api.IssueTemplate, error) {
4444

4545
// UnmarshalFromEntry parses out a valid template from the blob in entry
4646
func UnmarshalFromEntry(entry *git.TreeEntry, dir string) (*api.IssueTemplate, error) {
47-
return unmarshalFromEntry(entry, filepath.Join(dir, entry.Name()))
47+
return unmarshalFromEntry(entry, path.Join(dir, entry.Name())) // Filepaths in Git are ALWAYS '/' separated do not use filepath here
4848
}
4949

5050
// UnmarshalFromCommit parses out a valid template from the commit
@@ -109,7 +109,7 @@ func unmarshal(filename string, content []byte) (*api.IssueTemplate, error) {
109109
// It could be a valid markdown with two horizontal lines, or an invalid markdown with wrong metadata.
110110

111111
it.Content = string(content)
112-
it.Name = filepath.Base(it.FileName)
112+
it.Name = path.Base(it.FileName) // paths in Git are always '/' separated - do not use filepath!
113113
it.About, _ = util.SplitStringAtByteN(it.Content, 80)
114114
} else {
115115
it.Content = templateBody

0 commit comments

Comments
 (0)